- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Last working day of the 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
Forums
Discussions
Discussions
Forums
Discussions
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
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
01-15-2004 07:43 AM
01-15-2004 07:43 AM
I have searched the Forums and found a solution to the "last day of the month" using A. Clay's caljd.sh. I have not found a solution to determine the last working day of the month. For example, if the month ends on a Monday through Friday then it's very easy but if the month ends during the weekend or a holiday then I want the script to run before that. The other complication is that I want to run my scripts only once per month. For example, we typically are off from Christmas Eve until New Year's. I want the scripts to run only once for December.
I haven't been able to devise a method to do this. Any ideas out there?
Thanks,
David Yandry
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2004 08:05 AM
01-15-2004 08:05 AM
Re: Last working day of the month?
`date +%u` | read day
`date +%d` | read day_of_month
if [ $day -le 5 -a $day_of_month -ge 29 ]
then
do whatever
fi
Still prefer Clay's amny examples.
Best of luck.
Regards,
dl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2004 08:17 AM
01-15-2004 08:17 AM
SolutionYYYY_MM:DD
for each month that the conditions are first satisfied. The DD is appended so that you can know what day actually triggered the command. The script itself simply searches for an entry YYYY_MM: at the beginning of a line. If that line is found then the stuff's done been did for this here month but if'fn you don't find no such entry then you ain't done did the command. In that case, do that there commmand and write me an entry in this here file.
Something like this:
------------------------------------
#!/usr/bin/sh
DTFILE="/var/spool/donedates"
typeset -i10 STAT=0
if [[ $(caljd.sh -M) -ne $(caljd.sh -n 1 -x 6 -x 0 -h -M) ]]
then # last working day of month
typeset -i10 DO_IT=1
typeset DT=$(date '+%Y_%m:')
typeset DT_TARGET="^${DT}"
if [[ -f "${DTFILE}" ]]
then
grep -q -E "${DT_TARGET}" ${DTFILE}
FNDSTAT=${?}
if [[ ${FNDSTAT} -eq 0 ]]
then
DO_IT=0
fi
fi
if [[ ${DO_IT} -ne 0 ]]
then # we have not already done it this month
# Your commands go here and set STAT = 0
# if ok
#
# Now log the event to the date file so we only do this
# once per month
if [[ ${STAT} -eq 0 ]]
then
echo "${DT}$(date '+%d')" >> ${DTFILE}
fi
fi
fi
exit ${STAT}
--------------------------------
I was typing this "on the fly" so I hope there are no typo's.
That should do it, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2004 08:18 AM
01-15-2004 08:18 AM
Re: Last working day of the month?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2004 08:23 AM
01-15-2004 08:23 AM
Re: Last working day of the month?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2004 08:38 AM
01-15-2004 08:38 AM
Re: Last working day of the month?
Thanks,
David Yandry