A
A
Anton2016-10-18 12:39:40
linux
Anton, 2016-10-18 12:39:40

How to schedule CRON for specific days of the month?

I want to implement the execution of the command on specific days of the month. For example - 1, 10, 20 and 30 of each month.
Is this true?

* * 1,10,20,30 * * /command

And what do the first two zeros mean in the example below?
0 0 27-31 * *

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Pavlenko, 2016-10-18
@hummingbird

Not true. This means that it will be fulfilled every minute and hour on the 1st, 10th, 20th, 30th.
You need to specify two zeros, ie, 0 0 1,10,20,30 * * command
Thus, the execution will occur at 00:00 of the required numbers.
There is an excellent service that decrypts the meaning of cron commands:
crontab.guru/#0_0_1,10,20,30_*_*

C
CityCat4, 2016-10-18
@CityCat4

The first entry means "Run /command every minute of every hour on the 1st, 10th, 20th, 30th of every month of every day of the week."
The second entry means "Run (unspecified command) at 0 minutes 0 hours from the 27th to the 31st of each month of each day of the week"
The fields in the crontab are in the following order:
- Minute (0-59, leading zero can be omitted)
- Hour (0-23, zero is the same) - Day of the
month (1-31)
- Month (1-12)
- Day of the week (0-6, 0 - sunday )
If * is specified in the field, it means "any". If the field contains */(number) - this means "once in (number) units", for example */15 in the first field - once every fifteen minutes.
And all this can be read in man crontab :

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question