| From: | Steve Adams |
| Date: | 27-Apr-2001 15:55 |
| Subject: | Running a cron job fortnightly |
|
|
The command just needs to check whether it is an odd or even week as follows ... #----+-----+-----+-----+-----+------------------------------------------------- #min |hour |day |month|day |command # | |of mn| |of wk| #----+-----+-----+-----+-----+------------------------------------------------- 03 04 * * 4 expr `date +%W` % 2 >/dev/null || run_my_scriptThat will run the script on even weeks only. If you want odd weeks use
expr `date +%W` % 2 >/dev/null && run_my_script || true
to prevent cron from complaining about the non-zero return code. Also, watch out for the expr syntax for the mod/remainder function.
On some older versions of expr you need to use " instead of %.
|
![]() |
I would like to delete some files every OTHER Thursday. I know how to do it every Thursday but I need to skip a Thursday before running the script again. I would like to do this with cron. How?
|