topflight Posted May 28, 2010 Share Posted May 28, 2010 Quick question may somebody please tell me how can I run a simple PHP script every 15 mins every day every month, every week and etc.. lol Quote Link to comment https://forums.phpfreaks.com/topic/203157-php-scripts-cron-jobs/ Share on other sites More sharing options...
-Karl- Posted May 28, 2010 Share Posted May 28, 2010 You've stated how, via using a Cron Job. Quote Link to comment https://forums.phpfreaks.com/topic/203157-php-scripts-cron-jobs/#findComment-1064461 Share on other sites More sharing options...
jcbones Posted May 28, 2010 Share Posted May 28, 2010 Are you asking how to make a Crontab? http://adminschoice.com/crontab-quick-reference Quote Link to comment https://forums.phpfreaks.com/topic/203157-php-scripts-cron-jobs/#findComment-1064476 Share on other sites More sharing options...
topflight Posted May 28, 2010 Author Share Posted May 28, 2010 Well basically I need a script to be raned every 15mins without someone visiting the page. Quote Link to comment https://forums.phpfreaks.com/topic/203157-php-scripts-cron-jobs/#findComment-1064490 Share on other sites More sharing options...
trq Posted May 28, 2010 Share Posted May 28, 2010 So, take a look at the link in the previous reply. Quote Link to comment https://forums.phpfreaks.com/topic/203157-php-scripts-cron-jobs/#findComment-1064491 Share on other sites More sharing options...
topflight Posted May 28, 2010 Author Share Posted May 28, 2010 I am still confused, do I need to add a certain piece of code to the file I want to be executed? Quote Link to comment https://forums.phpfreaks.com/topic/203157-php-scripts-cron-jobs/#findComment-1064856 Share on other sites More sharing options...
trq Posted May 29, 2010 Share Posted May 29, 2010 If the script you want executed is a php script it should contain a shebang line on the very first line. This lets the shell know what program should execute your script. eg; #/usr/bin/php <?php // some php script ?> You can now simply put; 10 * * * * /path/to/your/script.php in your crontab. Otherwise, without the shebang, you need to actually specify what program to use to execute your script within the crontab entry; 10 * * * * /usr/bin/php /path/to/your/script.php Quote Link to comment https://forums.phpfreaks.com/topic/203157-php-scripts-cron-jobs/#findComment-1064882 Share on other sites More sharing options...
DWilliams Posted May 29, 2010 Share Posted May 29, 2010 I am still confused, do I need to add a certain piece of code to the file I want to be executed? I think your confusion here stems from the fact that you're only used to seeing PHP run on the web. PHP is a scripting language just like any other. If you stick it in a file and mark it executable you can pass it to the PHP CLI interpreter instead of having it called by apache or whatever webserver you're using. The procedure for setting up the cron job is exactly the same whether it's a shell script, python script, perl script, PHP script, or any other executable. Quote Link to comment https://forums.phpfreaks.com/topic/203157-php-scripts-cron-jobs/#findComment-1064902 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.