Calvin770D Posted April 15, 2008 Share Posted April 15, 2008 I was wondering if it is possible to create a script that would perform a specific task at a specific time every day? Link to comment https://forums.phpfreaks.com/topic/101238-scheduling-a-daily-event/ Share on other sites More sharing options...
jpratt Posted April 15, 2008 Share Posted April 15, 2008 set up a cron job on your server to call a specific php file. google cron jobs to see how it works. Link to comment https://forums.phpfreaks.com/topic/101238-scheduling-a-daily-event/#findComment-517856 Share on other sites More sharing options...
mbeals Posted April 15, 2008 Share Posted April 15, 2008 I am assuming you are linux....I know it can be done on windows, but don't know how. i actually rely on this quite a bit, so I'll give you some pointers (for unix) open a shell as the user who will be running the script. (IE if the script needs root privileges then you need to be in a root shell). type in crontab -e this will open up a nano editor with a line of text that looks like: # m h dom mon dow command This is where you specify the schedule and the script. Google search for how to specify the timing (it's easy), but a daily job, run at midnight all days of the week would look like: 0 0 * * * When you specify the scrip, you have to be specific, as cron's shell won't necessarily load the same env variables as your bash shell, so the 'PATH' variable may not be set. So to be safe, call the script as /usr/bin/php /absolute/path/to/script.php &> /dev/null Without the &> /dev/null, output and errors are sent as mail to the crontab's owner, which (for me) is a PITA, especially with the jobs I have running every minute. You can also redirect to a log file by changing /dev/null to the path of the log file. Link to comment https://forums.phpfreaks.com/topic/101238-scheduling-a-daily-event/#findComment-517913 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.