- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script to run every hr
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
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
тАО02-24-2009 12:59 PM
тАО02-24-2009 12:59 PM
I am having problems with the attached script when it runs at midnight (next day)...otherwise it runs fine.
Can you suggest what change I can make to run it every 5 mins past the hr successfully.
I don't want to use if statement though and I am running this thru cron.
Thanks,
Allan.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-24-2009 01:06 PM
тАО02-24-2009 01:06 PM
Re: Script to run every hr
Am I missing something? Why not 'cron' your script like this (?):
5 * * * * /path_to_script
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-24-2009 01:21 PM
тАО02-24-2009 01:21 PM
Re: Script to run every hr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-24-2009 01:34 PM
тАО02-24-2009 01:34 PM
SolutionInstead of fiddling around with time computations over midnight, use this Perl snippet:
# perl -MPOSIX -le 'print strftime "%Y%m%d %H",localtime(time()-3600)'
20090224 15
You can use the same 'date' formatting directives you are used to using. This code uses 3600 seconds or ONE hour ago.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-24-2009 01:35 PM
тАО02-24-2009 01:35 PM
Re: Script to run every hr
Broke how?
>>I am having problems with the attached
What kind of problems?
What does it do or not do when it runs after midnight?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-24-2009 01:39 PM
тАО02-24-2009 01:39 PM
Re: Script to run every hr
LASTHR=`expr $PRESENTHR - 1`
The problem is the above expressions.
When you run this during the midnight hour, which is the '0' hour, and you subtract 1 from, you get '-1'.
You need some logic to determine that '-1' should actually be hour 23 from yesterday. (I think JRF covers this in his response above.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-24-2009 02:49 PM
тАО02-24-2009 02:49 PM
Re: Script to run every hr
Just for my knowledge how would I handle this through "date" command.
Thanks
Allan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-24-2009 03:14 PM
тАО02-24-2009 03:14 PM
Re: Script to run every hr
> Just for my knowledge how would I handle this through "date" command
You would have to subtract your one-hour from the hour field and if that is negative, back off by one day; maybe to the previous month; and perhaps to the previous year...
Hence, why reinvent the wheel...
One helpful piece if you insist on taking this route, might be to install the GNU 'date' command which can do :
# date -d yesterday
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-24-2009 04:20 PM
тАО02-24-2009 04:20 PM
Re: Script to run every hr
A Clay's Date Hammer can be useful in these type of situations:
http://mirrors.develooper.com/hpux/caljd-2.25.sh
http://mirrors.develooper.com/hpux/caljd-2.2.pl
I ported it to Linux (A 1 line shell change), if you need.
Regards,
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Tags:
- caljd
- date hammer