Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a cron job on every Monday, Wednesday and Friday?

Tags:

cron

How can one run a cron job for every Monday, Wednesday and Friday at 7:00 pm?

like image 202
sona das Avatar asked Jul 07 '15 05:07

sona das


People also ask

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.

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 .


1 Answers

Here's my example crontab I always use as a template:

    # Use the hash sign to prefix a comment     # +---------------- minute (0 - 59)     # |  +------------- hour (0 - 23)     # |  |  +---------- day of month (1 - 31)     # |  |  |  +------- month (1 - 12)     # |  |  |  |  +---- day of week (0 - 7) (Sunday=0 or 7)     # |  |  |  |  |     # *  *  *  *  *  command to be executed     #-------------------------------------------------------------------------- 

To run my cron job every Monday, Wednesady and Friday at 7:00PM, the result will be:

      0 19 * * 1,3,5 nohup /home/lathonez/script.sh > /tmp/script.log 2>&1 

source

like image 175
lathonez Avatar answered Oct 16 '22 22:10

lathonez