<p>I have a site on my webhotel I would like to run some scheduled tasks on. What methods of achieving this would you recommend?</p>

<p>What I’ve thought out so far is having a script included in the top of every page and then let this script check whether it’s time to run this job or not.</p>

<p>This is just a quick example of what I was thinking about:</p>

<pre><code>if ($alreadyDone == 0 &amp;&amp; time() &gt; $timeToRunMaintainance) {
   runTask();
   $timeToRunMaintainance = time() + $interval;
} 
</code></pre>

<p>Anything else I should take into consideration or is there a better method than this?</p>

That's what cronjobs are made for.
```
man crontab
```
assuming you are running a linux server.  If you don't have shell access or no way to setup cronjobs, there are free services that setup cronjobs on external servers and ping one of your URLs.