Crontab cheat sheet: Difference between revisions

From Coolscript
Jump to navigation Jump to search
No edit summary
No edit summary
Line 11: Line 11:
  # *  *  *  *  *  command to be executed
  # *  *  *  *  *  command to be executed
   0  15 *  *  4  [ $(date +\%d) -le 07 ] && command
   0  15 *  *  4  [ $(date +\%d) -le 07 ] && command
0-7    1st week
7-14  2nd week
14-21  3rd week experimental
21-28  4th week experimental
28-31  5th week experimental


* 2nd Thursday of  month
* 2nd Thursday of  month
Line 21: Line 28:
  # |  |  |  |  |
  # |  |  |  |  |
  # *  *  *  *  *  command to be executed
  # *  *  *  *  *  command to be executed
   0  15 *  *  4  [ $(date +\%d) -ge 8 ] && [ $(date +\%d) -le 14 ] && command
   0  15 *  *  4  [ $(date +\%d) -ge 8 ] && [ $(date +\%d) -le 15 ] && command
 


*3rd wednesday of month
*3rd wednesday of month
0-7
8-15
16-23
24-31
  # Example of job definition:
  # Example of job definition:
  # .---------------- minute (0 - 59)
  # .---------------- minute (0 - 59)
Line 38: Line 40:
  # |  |  |  |  |
  # |  |  |  |  |
  # *  *  *  *  *  command to be executed
  # *  *  *  *  *  command to be executed
   5  03 *  *  WED  [ $(date +\%d) -ge 22 ] && [ $(date +\%d) -le 28 ] && /usr/bin/logger "Test 3rd Wed of month 03:05"
   5  03 *  *  WED  [ $(date +\%d) -ge 21 ] && [ $(date +\%d) -le 28 ] && /usr/bin/logger "Test 3rd Wed of month 03:05"





Revision as of 17:38, 24 January 2023

  • 1st Thursday of 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)
# |  |  |  |  |
# *  *  *  *  *   command to be executed
  0  15 *  *  4   [ $(date +\%d) -le 07 ] && command


0-7    1st week
7-14   2nd week
14-21  3rd week experimental
21-28  4th week experimental
28-31  5th week experimental
  • 2nd Thursday of 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)
# |  |  |  |  |
# *  *  *  *  *   command to be executed
  0  15 *  *  4   [ $(date +\%d) -ge 8 ] && [ $(date +\%d) -le 15 ] && command


  • 3rd wednesday of 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)
# |  |  |  |  |
# *  *  *  *  *   command to be executed
  5  03 *  *  WED   [ $(date +\%d) -ge 21 ] && [ $(date +\%d) -le 28 ] && /usr/bin/logger "Test 3rd Wed of month 03:05"


  • Reference

https://serverfault.com/questions/986514/crontab-first-wednesday-of-the-month-that-is-followed-by-the-first-monday-of-t
https://stackoverflow.com/questions/58413332/how-to-schedule-a-cron-for-the-first-thursday-of-every-month