Crontab / Cron / Cron Job Usage

This page answers questions like these:


Related Links:
Yesterday's Date using Shell Script Commands
Tomorrow's Date using Shell Script Commands
What Day of the Week Was It?
Is this Year a Leap Year? (using Shell Script Commands)



Useful Comment Block for the Top of a Crontab File:

# The fields below can be a star (i.e. *) meaning any value, a single number # (e.g. 2), a range (e.g. 4-6), or a list of numbers and ranges (e.g. 1,3-5,7). # Comment lines must start with #. # #Minute (0 to 59). #| Hour (0 to 23: 0=Midnight, 12=Midday, 23=11pm). #| | Day of the month (1 to 31). #| | | Month of the year (1 to 12: 1=January, 12=December). #| | | | Day of the week (0 to 6: 0=Sunday, 6=Saturday). #| | | | | Shell command to be executed. #| | | | | |


Run a Cron Job every 6 hours:

00 0,6,12,18 * * * COMMAND

Run a Cron Job every Saturday:

15 12 * * 6 COMMAND

Run a Cron Job on the First Day of the Month and every Sunday:

30 10 1 * 0 COMMAND

Run a Cron Job on the First Sunday of every Month:

45 12 1-7 * * test "`date +\%w`" -eq 0 && COMMAND

Run a Cron Job on the Fourth Friday of every month:

00 12 22-28 * * test "`date +\%w`" -eq 5 && COMMAND



Related Links:
Yesterday's Date using Shell Script Commands
Tomorrow's Date using Shell Script Commands
What Day of the Week Was It?
Is this Year a Leap Year? (using Shell Script Commands)

Home  >  Linux / Unix  >  Crontab / Cron / Cron Job Usage


Tags: cron, crontab, cron job, cronjob, cron security, cronjob security, cron job security, linux, unix, solaris, bsd, aix

Copyright © HelpDoco.com
crontab-usage.txt
Linux-Unix/crontab-cron-job-cronjob-usage.htm
6