1and1 Cron Job - Crontab Cronjob Examples
Cron jobs help you automate procedures such as backups, executing a file or sending an email. This page is a quick reference for creating a cron entry that defines when a specific application or script should execute.
Type “crontab -e” to edit your cron file. If you just want a listing, use “crontab -l” and if you want to delete a cron job, simply type “crontab -r”.
A line within a cron file will look like this:
1 2 3 4 5 /etc/myScript arguments
There are five numbers at the start of each line and represent the following:
1: minutes (0-59)
2: Hours (0-23)
3: Day (0-31)
4: Month (0-12 or January, February, … 0 and 12=December)
5: Day of the week(0-7 or Monday, Tuesday, Wednesday, … 0 and 7=Sunday)
You can also customize the commands even further, sor example:
*: applies everytime
1-4: start if 1,2,3 or 4 matche
1-4/2 step-by-step, here: 1 and 3
1,5,6: enumeration
*/3: every third
1-4,10-15: enummeration and range combined
To define the SHELL you would like to have execute and who you want to email the results to, use these commands:
SHELL=/bin/bash
MAILTO=myname@myhost
Cron Job - More Examples
# every day at 0:05
5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
# every first day of the month at 14:15
15 14 1 * * $HOME/bin/monthly
# on weekdays at 22:00
0 22 * * 1-5 mail -s “Adsense UP!” ken%Ken,%%Go buy something!%
# every day 23 minutes after every even hour (0:23, 2:23, …)
23 0-23/2 * * * $HOME/report.sh
# Sundays at 4:05
5 4 * * sun $HOME/backup1.sh full
# Every other day at 1:05am
5 1 */2 * * wget -q http://www.monetizers.com/adsense_clicklogger.php?R=