- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Cron jon schedule
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
Forums
Discussions
Discussions
Discussions
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
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
09-05-2006 08:45 PM
09-05-2006 08:45 PM
Can I schedule a cron job to start every last Friday of each month?
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2006 09:09 PM
09-05-2006 09:09 PM
Re: Cron jon schedule
crontab can't do it directly. However,for solution, see:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=371092
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2006 10:35 PM
09-05-2006 10:35 PM
Solutionschedule your job to run every Friday and include this at the start of your code.
thanks to Cem Tugrul:
## get actual day
DAY=`date +"%d"`
## get the last friday of curren month
EXEC_DAY=`cal | awk 'NF >=6 { last = $6 }; END{ print last }'`
if [ $DAY -ne $EXEC_DAY ]
then
echo " - Not run because is not the last friday - "
exit;
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2006 02:50 AM
09-06-2006 02:50 AM
Re: Cron jon schedule
-----------------------------------------
#!/usr/bin/sh
typeset -i STAT=0
PATH=${PATH}:/usr/local/bin
export PATH
if [[ $(caljd.sh -M) -ne $(caljd.sh -M -n 7) ]]
then
echo "It's the last Friday; do your thing"
# run your command and set ${STAT} approriately to indicate exit status
else
echo "It ain't; do nothing"
fi
exit ${STAT}
----------------------------------------
Install the attached caljd.sh in /usr/local/bin and invoke a caljd.sh -u for full usage and examples. Basically the idea is that we compare the month of the current date and the month 1 week later to see if they differ.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2006 05:13 PM
09-06-2006 05:13 PM