Crontab

Crontab definition: The software utility Cron is a time-based job scheduler in Unix-like computer operating systems. People who set up and maintain software environments use cron to schedule jobs (commands or shell scripts) to run periodically at fixed times, dates, or intervals. It typically automates system maintenance or administration—though its general-purpose nature makes it useful for things like connecting to the Internet and downloading email at regular intervals.[1] The name cron comes from the Greek word for time, χρόνος chronos. [source: Wikipedia]

Configuration:

 # * * * * *  command to execute
 # │ │ │ │ │
 # │ │ │ │ │
 # │ │ │ │ └───── day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
 # │ │ │ └────────── month (1 - 12)
 # │ │ └─────────────── day of month (1 - 31)
 # │ └──────────────────── hour (0 - 23)
 # └───────────────────────── min (0 - 59)
Entry Description Equivalent to
@yearly (or @annually) Run once a year at midnight of January 1 0 0 1 1 *
@monthly Run once a month at midnight of the first day of the month 0 0 1 * *
@weekly Run once a week at midnight on Sunday morning 0 0 * * 0
@daily Run once a day at midnight 0 0 * * *
@hourly Run once an hour at the beginning of the hour 0 * * * *
@reboot Run at startup @reboot

Examples:

Schedule Job
* * * * * echo “Run cron job every minute
*/5 * * * * echo “Run cron job every 5 minutes
*/30 * * * * echo “Run cron job every 30 minutes
0 * * * * echo “Run cron job every hour
0 */3 * * * echo “Run cron job every 3 hours
0 13 * * * echo “Run cron job every day at 1pm
30 2 * * * echo “Run cron job every day at 2.30am
0 0 * * * echo “Run cron job every day at midnight
0 0 * * 0 echo “Run cron job every Sunday
0 0 * * 1 echo “Run cron job every Monday
0 0 1 * * echo “Run cron job every first day of every month
0 0 1 1 * echo “Run cron job every first of January every year

Leave a Reply

Your email address will not be published. Required fields are marked *