pasychosheep Posted October 1, 2009 Share Posted October 1, 2009 Hey guys, first post(yaaaay!), and I've got an interesting problem that I'm not sure how to even go about doing. I need a PHP script to execute every hour, on the hour, 24 hours a day, without anyone externally loading a page or anything. I have a feeling I can't do this with just straight PHP, but I really don't know how to go about getting it to work. Can anyone help? Link to comment https://forums.phpfreaks.com/topic/176135-how-do-i-execute-a-script-once-every-hour/ Share on other sites More sharing options...
redarrow Posted October 1, 2009 Share Posted October 1, 2009 cron .... you need a cron job, it a program that let other programs execute via time set. http://cronw.sourceforge.net/ << windows version. most common version is free on lynx also used on most holsters. also for windows you can use the scheduler. http://support.microsoft.com/kb/308569 scheduler info. Link to comment https://forums.phpfreaks.com/topic/176135-how-do-i-execute-a-script-once-every-hour/#findComment-928137 Share on other sites More sharing options...
greatstar00 Posted October 1, 2009 Share Posted October 1, 2009 if you dont have cron job, the worst part is have this script include in all pages and check the last executed time, use the current subtract it if it is greater than 3600 seconds, then u execute that specific script Link to comment https://forums.phpfreaks.com/topic/176135-how-do-i-execute-a-script-once-every-hour/#findComment-928138 Share on other sites More sharing options...
pasychosheep Posted October 1, 2009 Author Share Posted October 1, 2009 Oh awesome, Cron's actually included with my host, just never knew what it did. I can figure it out from here, thanks for the quick response! Link to comment https://forums.phpfreaks.com/topic/176135-how-do-i-execute-a-script-once-every-hour/#findComment-928174 Share on other sites More sharing options...
redarrow Posted October 1, 2009 Share Posted October 1, 2009 professorial way. http://www.d9x.net/linux/guides/crons.php http://www.webmasterworld.com/forum23/80.htm The format of the entry looks like this: minute hour day-of-month month-of-year day-of-week command minute 00 through 59 hour 00 through 23 (midnight is 00) day-of-month 01 through 31 month-of-year 01 through 12 day-of-week 01 through 07 (Monday is 01, Sunday is 07) All five fields must be specified, but an asterisk can be used to match any time/date field. So to build an entry that would run "command" every fifteen minutes you would create a file with a text editor and place an entry in it like this: 15,30,45,59 * * * * command Which would run "command" at 15 min, 30 min, 45 min, and 59 min, of every hour, of every day, of every month, of every week. Let's say you named that file "schedule", you would then issue the command - crontab schedule It will then install your crontab file with the contents of "schedule" and create a new file named after your userid. You should not edit that file directly, instead add, delete, or modify the text file you created and issue the crontab command again, and it will replace the crontab file with the new contents. All going well, "command" should then run as scheduled. It's been a while since I did anything with cron, hope I haven't forgotten anything .... visual look easy way full tutorial http://www.siteground.com/tutorials/cpanel/cron_jobs.htm Link to comment https://forums.phpfreaks.com/topic/176135-how-do-i-execute-a-script-once-every-hour/#findComment-928233 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.