[wplug] Determine the "Last Full Week" of the month

Alheid, Gregory alheidgj at upmc.edu
Wed Oct 20 10:03:09 EDT 2010



> I have to work out a script (prefer bash in this case, but any will
> work) for work that will run on the 1 day of the week (sunday) but ONLY
> if it is the last full week of the month.

Kevin,

Here is one solution, not pretty but should work;


# Run every Sunday

# Months w 31 days
bigmth=" Jan Mar May Jul Aug Oct Dec"

# Current month
mth=$( date +%b )

demth=$( echo $bigmth | egrep $mth )

# Check to see if this is a month that has 31 days
if [ "x$demth" != "x" ] ; then

  # get todays date
  day=$( date +%d )
  
  # Ck to see if between 19th and 25th
  if [[ $day -gt 18 || $day -lt 26 ]] ; then

   echo "testing: execute script"

  fi

fi





More information about the wplug mailing list