Artificial intelligent assistant

Is it possible to schedule a cron job to run fortnightly? Is there a way to schedule a cron job to run every fortnight? (One way I can think of, within `crontab`, would be to add two entries for "date-of-month"...)

No, cron only knows about the day of the week, the day of the month and the month.

Running a command twice a month on fixed days (e.g. the 1st and the 16th) is easy:


42 4 1,16 * * do_stuff


Running a command every other week is another matter. The best you can do is to run a command every week, and make it do nothing every other week. On Linux, you can divide the number of seconds since the epoch (`date +%s`) by the number of seconds in a week to get a number that flips parity every week. Note that in a crontab, `%` needs to be escaped (cron turns `%` into newlines before executing the command).


42 4 * * 1 case $(($(date +\%s) / (60*60*24*7))) in *[02468]) do_stuff;; esac

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 68fbd90ea95a6be81cf344b3fce05cee