- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Date and Time Computing
Operating System - HP-UX
1753730
Members
4791
Online
108799
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО10-09-2002 10:43 AM
тАО10-09-2002 10:43 AM
Date and Time Computing
In my script I need to sleep (delay the next step) until a specified time. In my case it is 4:00 PM.
I came up with this:
perl -e '
($h, $m, $s) = (localtime)[2, 1, 0];
$diff = (16 * 60 * 60) - (($h*60*60) + ($m*60) + ($s));
sleep $diff > 1 ? $diff : 0;
'
Is there a more elegant way to accomplish this.
Thanks,
Leslie
I came up with this:
perl -e '
($h, $m, $s) = (localtime)[2, 1, 0];
$diff = (16 * 60 * 60) - (($h*60*60) + ($m*60) + ($s));
sleep $diff > 1 ? $diff : 0;
'
Is there a more elegant way to accomplish this.
Thanks,
Leslie
If life serves you lemons, make lemonade
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2002 11:13 AM
тАО10-09-2002 11:13 AM
Re: Date and Time Computing
you can have a look at the time modules.
Time::Local and Time::localtime and look at mktime ()
perl -e '
($h, $m, $s) = (localtime)[2, 1, 0];
$diff = (16 * 60 * 60) - (($h*60*60) + ($m*60) + ($s));
sleep $diff > 1 ? $diff : 0;
'
can be written
perl -e '
($s, $m, $h) = (localtime)[0..2];
$diff = (16 * 60 * 60) - (($h * 60 + $m) * 60 + $s);
sleep $diff > 1 ? $diff : 0;'
making it just a /bit/ more comprehensable
Time::Local and Time::localtime and look at mktime ()
perl -e '
($h, $m, $s) = (localtime)[2, 1, 0];
$diff = (16 * 60 * 60) - (($h*60*60) + ($m*60) + ($s));
sleep $diff > 1 ? $diff : 0;
'
can be written
perl -e '
($s, $m, $h) = (localtime)[0..2];
$diff = (16 * 60 * 60) - (($h * 60 + $m) * 60 + $s);
sleep $diff > 1 ? $diff : 0;'
making it just a /bit/ more comprehensable
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2002 11:20 AM
тАО10-09-2002 11:20 AM
Re: Date and Time Computing
Plan A:
Use the Time::Local timelocal function to compute the epoch seconds of a given date/time. That will also make it easier to cross day boundaries with your calculations.
Plan B.
Set up a signal handler and use the system() function to issue an at command to send your process a signal at a specified time.
Use the Time::Local timelocal function to compute the epoch seconds of a given date/time. That will also make it easier to cross day boundaries with your calculations.
Plan B.
Set up a signal handler and use the system() function to issue an at command to send your process a signal at a specified time.
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2002 11:25 AM
тАО10-09-2002 11:25 AM
Re: Date and Time Computing
Can't use at..
Its possible that cmd 1 in my script would be done by 4:00 before cmd 2, in this case I want no delay.
at would run it the next day:)
Its possible that cmd 1 in my script would be done by 4:00 before cmd 2, in this case I want no delay.
at would run it the next day:)
If life serves you lemons, make lemonade
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP