Crontab, how to plan the launch of the first Saturday of every month?

How to plan crontab launch on the first Saturday of every month?

+4
source share
5 answers

Try this (start at midnight on the first Saturday of the month):

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue...
# |  |  |  |  |
# *  *  *  *  * command to be executed
  0  0 1-7 *  *  [ $(/usr/bin/date +\%u) == 7 ] && command

Note

Symbol %must be reset in accordance withman 5 crontab

+4
source

This will start your work on the first Saturday of the month:

# First Saturday of the month

0 0 1-7 * * [ "$(date '+\%a')" == "Sat" ] && /home/scripts/your_script_file.sh
+1
source

.

script . script, , , , .

+1
# Example of job definition:
# .---------------- minute (0 - 59) / 0
# |   .------------- hour (0 - 23) / 10 at ten a.m.
# |   |  .---------- day of month (1 - 31) / 1-7  because 8 can't be first saturday
# |   |  |   .------- month (1 - 12)  /  * = every month 
# |   |  |   |     .---- day of week (0 - 6) (Sunday=0 or 7) / 1 = sat
# |   |  |   |     |
# *   *  *   *     * command to be executed
00   10  *   1-6   1

can be easily accomplished by working every month, at dates 1-7 and re-indicating busy days. Day 8 cannot be the first Saturday.

-1
source

You can directly use the name of the day.

0 0 1-7 * sat script file.

For more help see the link .

-1
source

Source: https://habr.com/ru/post/1568742/


All Articles