- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script to calculate duration
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
тАО04-14-2005 03:59 PM
тАО04-14-2005 03:59 PM
I have the following date time format:
start_date_time|stop_date_time
Jan 2 2005 7:45:57:206PM|Jan 2 2005 8:20:24:583PM
Wanted to get a duration = stop_date_time - start_date_time
Need help on scripting.
reagrds,
Munawar
Solved! Go to Solution.
- Tags:
- date arithmetic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-14-2005 04:27 PM
тАО04-14-2005 04:27 PM
Re: Script to calculate duration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-14-2005 04:31 PM
тАО04-14-2005 04:31 PM
Re: Script to calculate duration
Any would do. I would prefer in shell script.
But if you have one in perl, would great to share.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-14-2005 06:22 PM
тАО04-14-2005 06:22 PM
Re: Script to calculate duration
I created someting like that with a while loop that prints every timeout period to screen and kills the process after one hour :
MAX_TIMEOUT=3600 # Maximum backup time in seconds per process (3600 is one hour)
TIMEOUT="60" # Verify period of one minute
while (( $(UNIX95= ps -xC $(basename ${PROG}) |grep ${ORACLE_SID} |wc -w) > 0 ))
do
# wait for the timeout period
sleep ${TIMEOUT}
# update counter with one
(( counter +=1 ))
print counter=${counter}
# calculate total waiting time
(( wait_time=${counter}*${TIMEOUT} ))
# print backup time to screen
print backup ${ORACLE_SID} running ${wait_time} seconds
if (( ${wait_time} >= ${MAX_TIMEOUT} ))
then
print "Killing ${ORACLE_SID} backup process after ${wait_time} seconds"
kill $(UNIX95= ps -xC $(basename ${PROG}) -o pid | tail -1 )
fi
done
Hope it helps,
Renarios
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-14-2005 06:37 PM
тАО04-14-2005 06:37 PM
Re: Script to calculate duration
I just want to get a duration for each data and write it on next field.
Existing file:
|Jan 2 2005 7:45:57:206PM|Jan 2 2005 8:20:24:583PM|
Expected Result:
|Jan 2 2005 7:45:57:206PM|Jan 2 2005 8:20:24:583PM|
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-14-2005 07:14 PM
тАО04-14-2005 07:14 PM
Solution$ ./script.pl
Jan 2 2005 7:45:57:206PM|Jan 2 2005 8:20:24:583PM|2067
It prints out duration in seconds (you can redirect output to the new file).
The script disregards 3 digits before PM/AM. I assume this is fraction of millisecond.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-14-2005 07:15 PM
тАО04-14-2005 07:15 PM
Re: Script to calculate duration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-14-2005 07:17 PM
тАО04-14-2005 07:17 PM
Re: Script to calculate duration
for the solution you should read:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xea948cc5e03fd6118fff0090279cd0f9,00.html
A. Clay Stephenson's script does this and a lot more!
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-14-2005 07:31 PM
тАО04-14-2005 07:31 PM
Re: Script to calculate duration
I will try now..will let you know soon :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-14-2005 08:24 PM
тАО04-14-2005 08:24 PM
Re: Script to calculate duration
The script confuse on AM and PM cause the duration wrong. For example:
|Jan 5 2005 12:39:48:890AM|Jan 5 2005 1:15:17:173AM|-41071
|Jan 6 2005 11:58:58:303AM|Jan 6 2005 12:16:39:466PM|44261
|Jan 9 2005 12:56:18:443PM|Jan 9 2005 1:30:49:986PM|-41129