|
|
Question : Creating cron jobs in Linux
|
|
I have written a php script which needs to be run as a cron job. Could anyone tell me how this is done. The part that i am most concerned is the path that needs to be given for accessing a script and where, if it needs to set?? Also, is there a way i can set the default editor to pico instead of vi. I can access the Linux box both as root and from my username. By which user should i create the cron??
Please help..
Thanks for any help in advance
|
Answer : Creating cron jobs in Linux
|
|
Stefan already answered some of your questions. The missing piece is how to start the editor for your crontab file:
crontab -e Run this as the user you want to program to be executed as. Then edit a line like this:
5 * * * * /home/username/bin/do_something.php > /dev/null 2>&1
This will run the script /home/username/bin/do_something.php 5 minutes after the hour, every hour, every day. And it will redirect any output from the script to /dev/null. The different fields and the possible values are (I'm using wildcards for everthing but minutes): minute 0-59 hour 0-23 day of month 1-31 month 1-12 (or names, see below) day of week 0-7 (0 or 7 is Sun, or use names)
So to run your program on the first of the month at 1am, you would use: * 1 1 * * /path
|
|
|
|
|