crontab entry help (291 Views)
Reply
Super Advisor
rajesh73
Posts: 431
Registered: ‎03-17-2009
Message 1 of 3 (291 Views)

crontab entry help

 

Hi,

 

i want to disable the script every 1st and 3rd starturday. please help how make a crontab entry.

 

 

30 5 * * * /home/app.sh

 

 

Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,962
Registered: ‎03-06-2006
Message 2 of 3 (284 Views)

Re: crontab entry help

>i want to disable the script every 1st and 3rd Saturday. please help how make a crontab entry.

 

You can not.  You must put these checks into the script, since cron only ORs specs like that.

Add this near the top of your script:

# Check 2 & 3 Sat

set -A dates $(date +"%e %w")
#echo "Day, weekday: ${dates[0]}:${dates[1]}"

if (( ${dates[1]} == 6 && ${dates[0]} >= 8 && ${dates[0]} <= 21 )); then
   echo "Skipping second and third Saturdays"
   exit 0
fi

Please use plain text.
Valued Contributor
RAJD1
Posts: 60
Registered: ‎10-09-2011
Message 3 of 3 (278 Views)

Re: crontab entry help

 

Hi, 

 

- As per 1st & 3rd saturday to skip , per Dennis's script : you can use like below, in your script at the begining:

-Nothing can be done in the crontab entries.

 

 

Add this near the top of your script:

-----------

# Check 1st & 3rd  Satday to skip.

set -A dates $(date +"%e %w")
#echo "Day, weekday: ${dates[0]}:${dates[1]}"

 

# For 1st Saturday.
if (( ${dates[1]} == 6 && ${dates[0]} >= 1 && ${dates[0]} <=7 )); then
   echo "Skipping First  Saturdays"

   exit 0

fi

 

 

# For 3rd Saturday: 

if (( ${dates[1]} == 6 && ${dates[0]} >= 15 && ${dates[0]} <=21 )); then
   echo "Skipping Third   Saturdays"

   exit 0

fi

 

# End 1st/3rd satday skip check function.

-------------

 

 

 

Hth,

Raj D.

 

 

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation