Home   Profile   Fun
#42 Linux  03.04.2007

How to create cronjobs


Cron job syntax:
minute(0-59) hour(0-23) dayofmonth(1-31) month(1-12) dayofweek(0(sunday)-6) user commands

Run every minute
* * * * * user command1; command2; ...

Run every 5 minutes
*/5 * * * * user command1; command2; ...

Run every hour from 4 minutes until 10 minutes past the hour
4-10 * * * * user command1; command2; ...

Run every hour from 4 minutes until 10 minutes past the hour, but just every two minutes within this interval
4-10/2 * * * * user command1; command2; ...

Run on Mondays and Wednesdays at 8:30 am
30 8 * * 1,3 user command1; command2; ...

Run every hour, from 4 minutes until 10 minutes past the hour and from 20 minutes until 50 minutes past the hour. Within the first interval every minute, within the second interval every 5 minutes.
4-10,20-50/5 * * * * user command1; command2; ...

Print the cron jobs for the current user
crontab -l

Edit the cron jobs for the current user
crontab -e

Print the cron jobs for a particular user
crontab -u username -l

Edit the cron jobs for a particular user
crontab -u username -e