1745924 Members
4151 Online
108723 Solutions
New Discussion

crontab entry help

 
rajesh73
Super Advisor

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

 

 

2 REPLIES 2
Dennis Handly
Acclaimed Contributor

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

RAJD1
Valued Contributor

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.