Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set cron job for bi-weekly (twice a week)

Tags:

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 
like image 983
Elby Avatar asked Jan 02 '13 12:01

Elby


People also ask

What is the use of * * * * * In cron?

It is a wildcard for every part of the cron schedule expression. So * * * * * means every minute of every hour of every day of every month and every day of the week .

How do I schedule a cron job per week?

We can create that cron jobs by using crontab and list them using the crontab -l command. While creating, we can specify the date and time-related fields for the week or optionally a string that is provided of @weekly in the command for creating a cron weekly job.

How do I run a cron job every 2 days?

As we already know that the pattern * */2 * * * executes the task for every 2 hour, similary can * * */2 * * execute the task for every 2 day (once in 2 days).

How do I run cron in alternate days?

1 Answer. The cron statement for each script execute on the same days - */2 evaluates to 1-31/2 . See my answer here for more details. To get alternating days, you could use 2-31/2 for the first script - this would start at 2 and skip every other for 2,4,6 etc.


1 Answers

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?

like image 110
cmbuckley Avatar answered Sep 22 '22 11:09

cmbuckley