Crontab offset

How to run a cron job with an offset?

Quote:

To run a task every 20 minutes starting at 5 past the hour, try this:

 5-59/20 * * * *

Explanation

An * in the minute field is the same as 0-59/1 where 0-59 is the range and 1 is the step. The command will run at the first minute in the range (0), then at all successive minutes that are distant from the first by step (1), until the last (59).

Which is why */20 * * * * will run at 0 minutes, 20 minutes after, and 40 minutes after — which is the same as every 20 minutes. However, */25 * * * * will run at 0 minutes, 25 minutes after, and 50 minutes after — which is not the same as every 25 minutes. That’s why it’s usually desirable to use a step value in the minute field that divides evenly into 60.

So to offset the start time, specify the range explicitly and set the first value to the amount of the offset.

Examples

5-59/20 * * * * will run at 5 minutes after, 25 minutes after, and 45 minutes after.

10-59/25 * * * * will run at 10 minutes after and 35 minutes after.

1-59/2 * * * * will run every odd minute.

Ref.: Source

Advertisements

3 Comments on “Crontab offset”

  1. This is a subject matter tht is close to my
    heart… Many thanks! Where do your contact details though?

  2. Cheating says:

    Pretty! This is an extremely wonderful post.
    Many thanks for providing these records.

  3. Cristina says:

    I aam really loving the theme/design of your web site. Do you ever ruun into any browser compatibility
    issues? A small nnumber off my blog readers have
    complained about my site not operating correctly in Expplorer
    but looks great in Safari. Do yyou have any advice too help fix this issue?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s