BladeSystem Forums have moved here
To make BladeSystem information easier to find, we have moved the BladeSystem forums here, to Servers and Operating Systems.
Showing results for 
Search instead for 
Do you mean 

crontab entry help

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
Highlighted
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

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.