- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Get Current Time + 10 Minutes
Operating System - HP-UX
1821052
Members
2227
Online
109631
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
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
тАО11-09-1999 04:55 AM
тАО11-09-1999 04:55 AM
Get Current Time + 10 Minutes
Hello,
Does anyone know a simple way to find the time that is 10 minutes from
now? I have a shell script that needs to calculate the current time
plus 10 minutes and use that in a user message. I know I can use the
'date' command to get the system time in whatever format I want, but I
don't know how to add 10 minutes to the current time without parsing
through each digit and adding all the logic to do it.
Thanks,
Rob
Does anyone know a simple way to find the time that is 10 minutes from
now? I have a shell script that needs to calculate the current time
plus 10 minutes and use that in a user message. I know I can use the
'date' command to get the system time in whatever format I want, but I
don't know how to add 10 minutes to the current time without parsing
through each digit and adding all the logic to do it.
Thanks,
Rob
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-10-1999 08:18 AM
тАО11-10-1999 08:18 AM
Re: Get Current Time + 10 Minutes
There is a somewhat fudgy way of doing this that's easier than fully parsing
everything. I haven't worked it all the way through in quite awhile, but you
can start with this:
# echo `date +%M` + 10 | bc
The bc command will do the math, so you end up sending the command "## + 10"
through it for simple addition. Note that the date command is surrounded by
ticks, not apostrophes. This causes it to execute the date command.
This will produce a final number that is the minutes (10 from now). As long as
it's less than 60, you just echo the hour onto the front. If it's 60 or
greater, subtract 60 and echo the hour +1 in front of it (again using bc).
Of course, this works much better if you use 24-hour time. You won't need to
worry about the midnight hour unless you have people working all night.
everything. I haven't worked it all the way through in quite awhile, but you
can start with this:
# echo `date +%M` + 10 | bc
The bc command will do the math, so you end up sending the command "## + 10"
through it for simple addition. Note that the date command is surrounded by
ticks, not apostrophes. This causes it to execute the date command.
This will produce a final number that is the minutes (10 from now). As long as
it's less than 60, you just echo the hour onto the front. If it's 60 or
greater, subtract 60 and echo the hour +1 in front of it (again using bc).
Of course, this works much better if you use 24-hour time. You won't need to
worry about the midnight hour unless you have people working all night.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-15-1999 12:16 PM
тАО11-15-1999 12:16 PM
Re: Get Current Time + 10 Minutes
I know this is slightly off topic but you might consider using perl to write
your scripts. Date routines and many other things are much easier and it also
gives you more flexibility. For example to add 10 mins on to the current time
#!/bin/perl
$newtime = localtime (time + 10*60 );
print ("$newtime");
you can basically add or subtract seconds/mins/hours/days at will.
Hope this helps.
your scripts. Date routines and many other things are much easier and it also
gives you more flexibility. For example to add 10 mins on to the current time
#!/bin/perl
$newtime = localtime (time + 10*60 );
print ("$newtime");
you can basically add or subtract seconds/mins/hours/days at will.
Hope this helps.
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.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP