From LedHed's Wiki
Jump to: navigation, search
(Predefined scheduling definitions)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
== Overview ==
 
== Overview ==
 
Each user can have their own crontab. This allows users to schedule jobs to run at specific intervals.
 
Each user can have their own crontab. This allows users to schedule jobs to run at specific intervals.
 +
 +
=== Example ===
 +
0 */2 * * *  /home/username/test.sh
 +
 +
 +
* * * * *  command to be executed
 +
┬ ┬ ┬ ┬ ┬
 +
│ │ │ │ │
 +
│ │ │ │ │
 +
│ │ │ │ └───── day of week (0 - 7) (0 or 7 are Sunday, or use names)
 +
│ │ │ └─────── month (1 - 12)
 +
│ │ └───────── day of month (1 - 31)
 +
│ └─────────── hour (0 - 23)
 +
└───────────── min (0 - 59)
 +
 +
 +
===Predefined scheduling definitions===
 +
There are several special predefined values which can be used to substitute the CRON expression.
 +
 +
{| class="wikitable"
 +
|-
 +
!Entry                  !!Description                    !!Equivalent To
 +
|-
 +
|<code>@yearly (or @annually)</code>    ||Run once a year at midnight in the morning of January 1              ||<code>0 0 1 1  *</code>
 +
|-
 +
|<code>@monthly</code>  ||Run once a month at midnight in the morning of the first of the month              ||<code>0 0 1 * * </code>
 +
|-
 +
|<code>@weekly</code>    ||Run once a week at midnight in the morning of Sunday            ||<code>0 0 * * 0 </code>
 +
|-
 +
|<code>@daily</code>    ||Run once a day at midnight                ||<code>0 0 * * *</code>
 +
|-
 +
|<code>@hourly</code>    ||Run once an hour at the beginning of the hour              ||<code>0 * * * *</code>
 +
|-
 +
|<code>@reboot</code>    ||Run at startup              ||<code>@reboot</code>
 +
|}
  
 
=== View Job List ===
 
=== View Job List ===
 
  crontab -l
 
  crontab -l
 +
  
  

Latest revision as of 17:44, 14 January 2013

Overview

Each user can have their own crontab. This allows users to schedule jobs to run at specific intervals.

Example

0 */2 * * *  /home/username/test.sh


* * * * *  command to be executed
┬ ┬ ┬ ┬ ┬
│ │ │ │ │
│ │ │ │ │
│ │ │ │ └───── day of week (0 - 7) (0 or 7 are Sunday, or use names)
│ │ │ └─────── month (1 - 12)
│ │ └───────── day of month (1 - 31)
│ └─────────── hour (0 - 23)
└───────────── min (0 - 59)


Predefined scheduling definitions

There are several special predefined values which can be used to substitute the CRON expression.

Entry Description Equivalent To
@yearly (or @annually) Run once a year at midnight in the morning of January 1 0 0 1 1 *
@monthly Run once a month at midnight in the morning of the first of the month 0 0 1 * *
@weekly Run once a week at midnight in the morning of Sunday 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

View Job List

crontab -l


Add/Edit Job

crontab -e


Reference

http://en.wikipedia.org/wiki/Cron

http://www.freebsd.org/cgi/man.cgi?query=crontab&sektion=1&apropos=0&manpath=FreeBSD+9.0-RELEASE