syntax for bi-weekly cron job?

Paul M. Dyer pmdyer at ctgcentral2.com
Thu Dec 4 15:37:48 CST 2008


The syntax is:

# Minute  Hour  Day   Month  Weekday  Command
# 0-59    0-23  1-31  1-12   0-6

To run every Monday would be:

* * * * 1 commands   (the weekday starts from Sunday (0))

To do every other Monday, you would have to do something in the bash script to decide if you should continue:

#!/bin/bash
shopt -s extglob
declare -r today=$(date +%d%b%Y)
declare    day2=$(date +%d)
declare -i day=${day2#0}
if (( $day < 7 )); then
  echo "run my job"
  fi
if (( $day >= 7 && $day < 14 )); then
  exit
  fi
if (( $day >= 14 && $day < 21 )); then
  echo "run my job"
  fi
if (( $day >= 21 && $day < 28 )); then
  exit
  fi
if (( $day >= 28 )); then
  echo "run my job"
  fi


----- Original Message -----
From: "Brandon Coale" <brandoncoale at sbcglobal.net>
To: Linux-PowerEdge at dell.com
Sent: Thursday, December 4, 2008 1:21:26 PM (GMT-0600) America/Chicago
Subject: syntax for bi-weekly cron job?

Hi,

I use RHEL4 on a DELL PowerEdge server, and I want to have a cron job run at 8:30 AM every other Monday.  I think this might be the right syntax:

30 8 */14 * mon command

What I'm not sure of is if this means the Monday has to fall on the 14th of the month, or if it means every 14 days?

Thank you,
Brandon Coale

_______________________________________________
Linux-PowerEdge mailing list
Linux-PowerEdge at dell.com
http://lists.us.dell.com/mailman/listinfo/linux-poweredge
Please read the FAQ at http://lists.us.dell.com/faq



More information about the Linux-PowerEdge mailing list