waddledoo Posted December 6, 2011 Share Posted December 6, 2011 Is there a way of having a PHP script execute automatically every X amount of time? For example, every 15 minutes; or every week. Specifically, while running on a web host server (not my own machine). Quote Link to comment https://forums.phpfreaks.com/topic/252549-autorunning-php-script/ Share on other sites More sharing options...
tomfmason Posted December 6, 2011 Share Posted December 6, 2011 yes, you will need to setup a cron job in linux or a scheduled task in windows. Quote Link to comment https://forums.phpfreaks.com/topic/252549-autorunning-php-script/#findComment-1294787 Share on other sites More sharing options...
dweeber Posted December 6, 2011 Share Posted December 6, 2011 If your web host allows you to use Cron yes. You can schedule either a call to the PHP CLI to execute your code, or use something like Curl or Wget to execute the PHP code you want. Quote Link to comment https://forums.phpfreaks.com/topic/252549-autorunning-php-script/#findComment-1294788 Share on other sites More sharing options...
waddledoo Posted December 6, 2011 Author Share Posted December 6, 2011 Alright, the webhost does allow use of Cron. I have never used it before; is it as simple as giving it a code and telling it when to run it? Quote Link to comment https://forums.phpfreaks.com/topic/252549-autorunning-php-script/#findComment-1294791 Share on other sites More sharing options...
dweeber Posted December 6, 2011 Share Posted December 6, 2011 Not enough info to answer that. Depends on how your web host allows you to configure cron entries. Could be anything from a simple Cpanel like interface to regular raw Unix cron formatted setup. Chances are, your Web host has a FAQ on how to do it for their servers or a knowledge-base with that info. Quote Link to comment https://forums.phpfreaks.com/topic/252549-autorunning-php-script/#findComment-1294792 Share on other sites More sharing options...
waddledoo Posted December 6, 2011 Author Share Posted December 6, 2011 Alright, thanks. I'll use Task Scheduler on my machine to test the code, while I figure out the webhost's system Quote Link to comment https://forums.phpfreaks.com/topic/252549-autorunning-php-script/#findComment-1294794 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.