hno Posted September 1, 2009 Share Posted September 1, 2009 HI Is it possible to execute a page daily automatically by the server without opening that page by the user? It's like a task scheduler that execute a php page daily. Thanks Link to comment https://forums.phpfreaks.com/topic/172656-execute-a-page-daily/ Share on other sites More sharing options...
trq Posted September 1, 2009 Share Posted September 1, 2009 Yes. You need to tell your systems task scheduler (cron on Linux) to execute your script at a given time. Link to comment https://forums.phpfreaks.com/topic/172656-execute-a-page-daily/#findComment-910098 Share on other sites More sharing options...
hno Posted September 1, 2009 Author Share Posted September 1, 2009 But I can't find that on my host. What is the name of that in the hosts? Link to comment https://forums.phpfreaks.com/topic/172656-execute-a-page-daily/#findComment-910122 Share on other sites More sharing options...
trq Posted September 1, 2009 Share Posted September 1, 2009 Depends on your hosts control panel I guess. I always host my own sites so... Look for crontab or cronjob if your hosted on Linux. Windows (or even cheap Linux hosts) will likely not offer such functionality. Link to comment https://forums.phpfreaks.com/topic/172656-execute-a-page-daily/#findComment-910125 Share on other sites More sharing options...
Goldeneye Posted September 1, 2009 Share Posted September 1, 2009 Or... something like this might work... <?php ignore_user_abort(1); // run script in background set_time_limit(0); // run script forever $interval=60*15; // do every 15 minutes... do{ // add the script that has to be ran every 15 minutes here // ... sleep($interval); // wait 15 minutes }while(true); ?> The code was found here: http://us2.php.net/manual/en/function.ignore-user-abort.php Of course, you can change $interval to whatever you want. For example, running a script every 24 hours would be something like, "$interval = 60 * 60 * 24;" Link to comment https://forums.phpfreaks.com/topic/172656-execute-a-page-daily/#findComment-910126 Share on other sites More sharing options...
trq Posted September 1, 2009 Share Posted September 1, 2009 You would need shell access to execute this script. If you have shell access you have cron. No need to write your own daemon when a perfectly goods one already exists. Link to comment https://forums.phpfreaks.com/topic/172656-execute-a-page-daily/#findComment-910137 Share on other sites More sharing options...
Goldeneye Posted September 1, 2009 Share Posted September 1, 2009 You would need shell access to execute this script. If you have shell access you have cron. No need to write your own daemon when a perfectly goods one already exists. I was not aware of that. Thanks for the enlightenment. So, either method would work, but there's no need to reinvent the wheel. Link to comment https://forums.phpfreaks.com/topic/172656-execute-a-page-daily/#findComment-910143 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.