31

How do I set a cron job to run twice a week?

I know how to set a cron job for every week:

0 0 * * 0
1

3 Answers 3

61

How about the following:

0 0 * * 1,4

This sets the day of week to Monday (1) and Thursday (4). You can choose any values 0–7 (both 0 and 7 are Sunday).

For a more readable crontab, you can also use names:

0 0 * * MON,THU

See also: How to instruct cron to execute a job every second week?

2
  • I want to set cron for 2 times in a Month. Set cron for once at a 2 week
    – Elby
    Commented Jan 9, 2013 at 5:14
  • 8
    Biweekly is an ambiguous phrase; in the UK it tends to mean twice a week. For "every other week" we use fortnightly :-) See Petesh's comment above for a related question.
    – cmbuckley
    Commented Jan 9, 2013 at 9:34
5

In reply to Elby question :

0 0 1,15 * *

This will set cronjob for (fortnight) 2 times in a Month i.e 1st day and 15th day of a month.

2

These answers are great, but I wanted to share a tool I found right after looking at this question and answers called crontab.guru. I'm not affiliated, I just thought it was a nice tool.

crontab.guru for 'At 00:00 on Monday and Thursday.'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.