Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
cancel
Showing results for 
Search instead for 
Did you mean: 

crontab entry help

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