Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cron Job only specific months

I would like to set up a cron task to run a script every first day of every month except 1st january. How can I do that?

Could I try something like that: 0 0 1 2-12 * ?

like image 929
Francesco Avatar asked Dec 04 '15 10:12

Francesco


People also ask

How we can set crontab for month end?

Some cron implementations support the "L" flag to represent the last day of the month. If you're lucky to be using one of those implementations, it's as simple as: 0 55 23 L * ? That will run at 11:55 pm on the last day of every month.

How do you create a cron job that runs on the last day of the month?

Identify Last Day of Month So, first of all, we will schedule cron on the 28,28,29 and 31'st of each month. Now find out if today is the last day of the month. To find it check if the next day is 01'st of the next day and then only execute any command. Below command will return the date of the next day.

How do I schedule a cron to run on the first Sunday of every month?

You need to combine two approaches: a) Use cron to run a job every Sunday at 9:00am. b) At the beginning of once_a_week , compute the date and extract the day of the month via shell, Python, C/C++, ... and test that is within 1 to 7, inclusive. If so, execute the real script; if not, exit silently.

What is cron monthly?

Cron is a powerful tool in linux-based operating systems to execute jobs at specified intervals. This easy hack makes monthly cron jobs execute at a specific date. The easiest way to execute a script as a scheduled job is to put your script executable file on cron folders: /etc/cron.


1 Answers

It can be something like below:

0 0 1 2,3,4,5,6,7,8,9,10,11,12 *

like image 121
Rushabh Patel Avatar answered Sep 23 '22 14:09

Rushabh Patel