- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- cron job that runs second sunday of every month
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-14-2007 01:44 PM
тАО08-14-2007 01:44 PM
cron job that runs second sunday of every month
May I know how to run a cron job that runs on every second sunday of every month.
Thanx in advance :)
- Tags:
- crontab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-14-2007 02:25 PM
тАО08-14-2007 02:25 PM
Re: cron job that runs second sunday of every month
#!/usr/bin/sh
set -u
DAY= $(date "+%d")
[ $DAY -ge 8 -a $DAY -le 14 ] || exit
... rest of your script ...
Then in cron, the entry would be:
1 1 * * 0 /somepath/myscript
where 1 1 = minute and hour to run
* * = day and month don't matter
0 = only on Sunday
Your script runs every Sunday at 01:01 in the morning, but immediately exits in the day is not 8 through 14.
Bill Hassell, sysadmin
- Tags:
- date arithmetic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-14-2007 02:57 PM
тАО08-14-2007 02:57 PM
Re: cron job that runs second sunday of every month
---------------------------------------------
#!/usr/bin/sh
export PATH=${PATH}:/usr/local/bin
typeset -i STAT=0
if [[ $(caljd.sh -N) -eq 2 ]]
then
echo "It's the 2nd Sunday; do your thing"
STAT=${?}
fi
exit ${STAT}
-------------------------------------------
Invoke as caljd.sh -u for full usage and many examples.
- Tags:
- caljd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-14-2007 03:00 PM
тАО08-14-2007 03:00 PM
Re: cron job that runs second sunday of every month
---------------------------------------------
#!/usr/bin/sh
export PATH=${PATH}:/usr/local/bin
typeset -i STAT=0
if [[ $(caljd.sh -N) -eq 2 ]]
then
echo "It's the 2nd Sunday; do your thing"
STAT=${?}
fi
exit ${STAT}
-------------------------------------------
Invoke as caljd.sh -u for full usage and many examples.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-14-2007 11:05 PM - edited тАО09-24-2011 07:34 PM
тАО08-14-2007 11:05 PM - edited тАО09-24-2011 07:34 PM
Re: cron job that runs second Sunday of every month
Here are two other threads that want the first Sunday. My suggestion was to do it on the date range of 8-14 and then your script only has to check for Sunday.
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1096366
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1131448
The reason it isn't directly possible in cron is that it ORs the day of month range with the day of week. (With tzab, it does an AND.)