Crontab example

Dec 07
0

Crontab example

Thu, 2006-12-07 21:09 — superuser

To edit crontab firstly run crontab -e

You might all this below useful to have a reference in the file itself, it's fairly self explanatory

# (Use to post in the top of your crontab)
# ------------- minute (0 - 59)
# | ----------- hour (0 - 23)
# | | --------- day of month (1 - 31)
# | | | ------- month (1 - 12)
# | | | | ----- day of week (0 - 6) (Sunday=0)
# | | | | |
# * * * * * command to be executed
0,20,40 * * * * /var/www/scripts/cron-curl.sh 2>&1 >> /dev/null
30 6 * * * /root/automysqlbackup.sh 2>&1 >> /dev/null

The first runs on the hour, 20 past and 20 to every hour, every hour,day,month,week

Also note rather than using 0,20,40 you can use */20 for every 20 minutes - it's obviously quicker to use */2 than 0,2,4,6,8 etc.

The second runs every day at 6:30 (AM)

By default cron jobs sends a email to the user account executing the cronjob, the 2>&1 >> /dev/null prevents this

crontab -l lists the current jobs whilst
crontab -r removes them

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].

More information about formatting options