Defining user crontabs (scheduled tasks) on UNIX systems
UNIX’s cron service runs scheduled tasks at dates and times defined by users in crontab files. A user can check their crontab entries from the command line by entering:
crontab -l… or check another user’s crontab by entering:
sudo crontab -u {username} -l
Crontabs entries are defined as follows:
{minute (*-0-59)} {hour (*-0-23)} {monthday (*-1-31)} {month (*-1-12)} {weekday (*-0-7)} {path} {script}
For example, to execute a script once an hour on Mondays, you would use:
0 * * * 1 /usr/bin/php5 the_script.php
To override crontab settings, edit a crontab with either one of these commands:
crontab -e sudo crontab -u {username} -e
… or create a text file containing cron entries:
0,30 * * * * /usr/bin/php5 /home/willem/something.php 0 23 * * 0,3 sh /home/willem/cronscripts/run_backup.sh 0 */2 * * * /usr/bin/php5 /var/www/geekology/sitemap.php
If you created a text file, load it to your or another user’s crontab by entering:
crontab {path_to_text_file} sudo crontab -u {username} {path_to_text_file}
Related posts:



22 Feb 2009 








author
No comments yet... Be the first to leave a reply!