#!/bin/bash # If you only want a cron job to run every-other-week # you can use a method like this to track if it was # run last week or not. # Steve Parker, 2016 # Requires GNU date # File to record when this was last run lastrun=/tmp/last-run.txt lastweek=`date +%G%V -d "now - 1 week"` if [ "$lastweek" == "`cat $lastrun`" ]; then echo "Not running the main program; it was run last week" exit 0 else # Log that we ran this time date +%G%V > $lastrun /path/to/run-biweekly-program.sh fi