- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- caljd script
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
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
07-25-2005 02:57 PM
07-25-2005 02:57 PM
Determine the month 3 days from now unless that falls on a weekend; output in full monthname format:
JD=$(caljd.sh -n 90 -x 6 -x 0 -M -O)
Is this correct?
Can I run it in a cron daily?
10 points for a good answer
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2005 02:59 PM
07-25-2005 02:59 PM
Re: caljd script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2005 04:05 PM
07-25-2005 04:05 PM
Solution#!/usr/bin/sh
PATH=${PATH}:/usr/bin:/usr/local/bin
export PATH
CAL90=$(caljd.shi -S "/" $(caljd.sh -n 90))
echo "90 days from now is ${CAL90}."
Now if you want 90 days from today but if that lands on a Saturday (-x 6) or Sun (-x 0) skip to the next day then:
CAL90=$(caljd.sh -S "/" $(caljd.sh -n 90 -x 6 -x 0))
echo "90 days from now is ${CAL90}."
If you keep your /etc/acct/holidays file current, you can even add -h and it will also skip past holidays.
CAL90=$(caljd.sh -S "/" $(caljd.sh -n 90 -x 6 -x 0))
echo "90 days from now is ${CAL90}."
The inner caljd.sh takes today's date and converts it into a Julian Day (number of days since 4713BCE. The outer caljd.sh then takes this Julian Date and converts it to mm/dd/yyyy.
Your approach would print out the Monthname (e.g. September) 90 days from today.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2005 04:32 PM
07-25-2005 04:32 PM
Re: caljd script
Most definitely, I am going to write a small script to ivoke your script!
10 points for you Sir!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2005 04:49 PM
07-25-2005 04:49 PM
Re: caljd script
I've seen your thread:
if [[ $(caljd.sh -M -n 1 -x 6 -x 0) -ne $(caljd.sh -M) ]]
then
echo "Last working day of the month; do your thing"
else
exit 0
fi
So in my case, it'll be something like this:
if [[ $(caljd.sh -n 90 -x 6 -x 0) -ne $(caljd.sh ) ]] > whatever
then
mailx -s " It's been 90 days now..." email@domain.com < whatever
else
exit 0
fi
Any corrections?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2005 02:51 AM
07-26-2005 02:51 AM
Re: caljd script
if [[ $(caljd.sh -n 90 -x 6 -x 0) -ne $(caljd.sh ) ]] > whatever
then
mailx -s " It's been 90 days now..." email@domain.com < whatever
else
exit 0
fi
No, this is not a valid use for caljd.sh. You are essentially asking if (today + 90 days) <> today. That question will always be true.
A much better approach would be to create a script something like this using the at command:
--------------------------------------
#!/usr/bin/sh
PROG=${0}
PATH=${PATH}:/usr/bin/:/usr/local/bin
export PATH
mailx -s "It's been " < whatever
at -f ${PROG} now + 90 days
--------------------------------------
This will reschedule the same script 90 days from now after sending mail.
A slight variation if you wanted to skip weekends and holidays would be (and now we will use caljd.sh):
--------------------------------------
#!/usr/bin/sh
PROG=${0}
PATH=${PATH}:/usr/bin/:/usr/local/bin
export PATH
typeset -i DT90A=$(caljd.sh -n 90)
typeset -i DT90B=$(caljd.sh -n 90 -x 0 -x 6 -h)
typeset -i DIFF=0
typeset -i DAYS=90
DIFF=$(( ${DT90B} - ${DT90A} ))
(( DAYS += ${DIFF} ))
mailx -s "It's been " < whatever
at -f ${PROG} now + ${DAYS} days
--------------------------------------
The idea is that is today + 90 days lands on a weekend or holiday we need to skip to the next excluded day; otherwise ${DIFF} = 0 and ${DAYS} remains at 90.
Man at for details.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2005 02:48 PM
07-26-2005 02:48 PM
Re: caljd script
Let's not worry about the cron and the holidays + weekends.
All I wanted is to use your script to execute a command every 90 days. Can this be done using your script caljd.sh
Cron job can do that I know, but I wanted to use your script as a counter to run some commands every 90 days?
Many thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2005 02:56 PM
07-26-2005 02:56 PM