Subject: Examples
Author: Linux
In response to: Crontab format
Posted on: 09/03/2012 05:33:14 PM
Example #1. Run task at 1AM every Monday
0 1 * * 5 /bin/execute/this_script.sh
Example #2. Run task at 1AM every Monday to Friday
0 1 * * 1-5 /bin/execute/this_script.sh
Example #3. Run task daily
@daily /bin/execute/this_script.sh
>
> On 09/03/2012 05:27:01 PM
Linux wrote:
Cronjobs are expressed in two formats: in number or in keyword.
Numberical format
* * * * * /bin/execute/this_script.sh
As you can see there are 5 stars. The stars represent different date parts in the following order:
1st * -- minute (from 0 to 59)
2nd * -- hour (from 0 to 23)
3rd * -- day of month (from 1 to 31)
4th * -- month (from 1 to 12)
5th * -- day of week (from 0 to 6) (0=Sunday)
Note: If you leave the star, or asterisk, it means every. By default, ***** means that the task is being executed every minute.
Keyword format
@<keyword> /bin/execute/this_script.sh
Here are some useful keywords instead of a number:
@reboot Run once, at startup
@yearly Run once a year "0 0 1 1 *"
@annually (same as @yearly)
@monthly Run once a month "0 0 1 * *"
@weekly Run once a week "0 0 * * 0"
@daily Run once a day "0 0 * * *"
@midnight (same as @daily)
@hourly Run once an hour "0 * * * *
References: