Not exactly command line but does have to be typed. ;)

Dart

Active Member
Joined
Jan 5, 2022
Messages
112
Reaction score
132
Credits
1,194
If you've ever wanted to have a cron job run on something other than a daily, weekly or monthly schedule. This might help.

This is the crontab entry that will run a program on the first Monday of the month at 8AM.
the first 0 is the minute, the 08 is 8AM 1-7 is days of the month it's can run on, */4 every fourth month the * is every day of the week.
Remember it's already been limited to the first 7 days of the month.
The formula in [ ] brackets matches the day number to it's name, that is IF the Date number converts to Mon (or 1) the && (is true) run your program.

# field allowed values
# ----- --------------
# --------------- minute 0-59
# | ------------- hour 0-23
# | | ----------- day of month 1-31
# | | | --------- month 1-12 (or names, see below)
# | | | | ------- day of week 0-7 (0 or 7 is Sun, or use names)
# | | | | |
# * * * * * Job to be run

MAILTO="[email protected]"
######################################################################
# Reminder to clean computer room air filters every four months.
######################################################################
0 08 1-7 */4 * [ "$(date '+\%a')" == "Mon" ] && /usr/local/bin/your_program.sh
 

Members online


Latest posts

Top