Skip to content

Instantly share code, notes, and snippets.

@lakshmantgld
Last active May 21, 2018 02:27
Show Gist options
  • Save lakshmantgld/08f839983607202fe53c085fa8a60079 to your computer and use it in GitHub Desktop.
Save lakshmantgld/08f839983607202fe53c085fa8a60079 to your computer and use it in GitHub Desktop.
Documenting cronJob with examples

Cron is an utility program which is a time-based job scheduler in Unix-like computer operating systems. It can also be combined with AWS Lambda to invoke function based on the time-scheduler.

CronJob is represented as space-delimited 5 character string. Here is the syntax:

+---------------- minute (0 - 59)
 |  +------------- hour (0 - 23)
 |  |  +---------- day of month (1 - 31)
 |  |  |  +------- month (1 - 12)
 |  |  |  |  +---- day of week (0 - 6) (Sunday=0 or 7)
 |  |  |  |  |  |- year
 *  *  *  *  *  *  command to be executed 

Examples:

1. Running a job every minute:

* * * * * * - This will run the job every minute.

2. Running a job every day:

0 0 * * * * - This will run the job everyday at 00:00.

3. Running a job every monday at 07:00:

0 7 * * 1 * - This will run the job every monday at 07:00.

4. Running a job every weekend at 10:00:

0 10 * * 0,6 * - This will run the job every saturday and sunday at 10:00. 0 represents sunday and 6 represents saturday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment