Cronjob

How to set cronjob for 48 hours.

I can set for 2 days as shown below.

    • */2 * *

It is creating confusion for 30 days & 31 days per month.

Set it to daily, and let the cron job skip every second time.
Example:

59 23 * * *  tf=/tmp/tf; if [ -d $tf ]; then rmdir $tf; /path/to/realcronjob; else mkdir $tf; fi

As root the protected /var/run/ is safer than /tmp/.

2 Likes

this below cron will work.

0 0 2-31/2 * * command2

When the calendar days are 28,29,30,31,1,2,3,4 it will run the red days, and you see that the "every second day" rule is violated.