Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to run a job using crontab every other Monday. Is it possible?

share|improve this question

migrated from stackoverflow.com Aug 16 '10 at 18:29

This question came from our site for professional and enthusiast programmers.

3 Answers 3

Put '1/2' in the day of the week field. This will work with VixieCron and Anacron, but it won't work with the older versions of cron.

share|improve this answer

No experience here with VixieCron or Anacron; if you're using one of them, try Paul Tomblin's answer. If you're not, you could set up a shell script something like the following:

FLAG_FILE="alternate_monday_flag_file"
if [ -e $FLAG_FILE ]
then
  # Replace this comment with a call to the script you really want to run
  chmod u+w  $FLAG_FILE
  rm $FLAG_FILE
else
  touch $FLAG_FILE
  chmod u-w $FLAG_FILE
fi

Just make sure this is the only job that will do anything with the alternate_monday_flag_file. The chmod u+w before the rm and chmod u-w after the touch are there to help ensure that.

share|improve this answer

Might as well use (Roaring Penguin's) remind if you are going to use more than just a crontab entry.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.