- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need to execute a task every 10 days
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
08-20-2007 07:03 AM
08-20-2007 07:03 AM
I have a requirement to execute a task at the same time every 10 days. I can't get cron to do this. Any ideas?
TIA,
Greg
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2007 07:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2007 07:12 AM
08-20-2007 07:12 AM
Re: Need to execute a task every 10 days
I would let the script run every day at the appointed time and let it decide if it is the 10th day. If so, execute else exit immediately. You should have no trouble finding a copy of caljd.sh. I'll assume that you have installed it in /usr/local/bin.
--------------------------------
#!/usr/bin/sh
export PATH=${PATH}:/usr/local/bin
typeset -i DAY=0
typeset -i DO_DAY=5 # set between 0-9
typeset -i STAT=0
DAY=$(($(caljd.sh) % 10))
if [[ ${DAY} -eq ${DO_DAY} ]]
then
echo "Do your thing"
STAT=${?}
fi
exit ${STAT}
--------------------------------------
set DO_DAY to a value between 0 and 9 because I don't know on which day you wish to start.
By the way, DON'T try to use date '+%j' because year boundaries are going to kill you. Caljd.sh will return an integer for each day indicating days since 4713BCE.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2007 07:14 AM
08-20-2007 07:14 AM
Re: Need to execute a task every 10 days
DAY=$(perl -Minteger -e 'print ((time() / 86400) % 10)'
if [[ ${DAY} -eq ${DO_DAY} ]]
then
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2007 07:48 AM
08-20-2007 07:48 AM
Re: Need to execute a task every 10 days
Wow, you guys are quick. I think I will use A. Clay's approach because as he pointed out if my task ever fails, it won't automatically restart. I am concerned that running the task everyday might put a load on my machine so the at approach is better from that perspective.
Thanks,
Greg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2007 07:56 AM
08-20-2007 07:56 AM