- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Monitor script running time
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
12-09-2002 11:01 AM
12-09-2002 11:01 AM
Monitor script running time
I need to develop a script which can monitor the time a script runs from start to finish. This particular project requires the script doing the monitoring run externally from the scripts it is monitoring, monitor multiple scripts simultaneously, get the timestamp down to the second and have as little overhead as possible.
My first thought was to have a background process grep a 'ps -ef' and look for specific indicators of a script running (like a script???s name.) When it finds a script running, grab a timestamp and then when the script is no longer there, get another timestamp and do a comparison. The problem I see (besides a lot of overhead) is if the script does a 'ps -ef' every second, and takes one second to calculate everything when it sees/stops seeing a process...there would be an up-to-4-second corruption on the actual time the script ran.
Is there a way to have the script monitor a process, or process ID, with more accuracy and less overhead? I can use UNIX shell scripting or Java is a possibility as well.
Thanks!
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2002 11:04 AM
12-09-2002 11:04 AM
Re: Monitor script running time
Have you looked into the time command?
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2002 11:06 AM
12-09-2002 11:06 AM
Re: Monitor script running time
no need to develop.
You can use timex (1m).
Hope this helps,
0leg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2002 11:08 AM
12-09-2002 11:08 AM
Re: Monitor script running time
Either use "time" to run the script and save those results, or run "date" before and after the script.
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2002 11:14 AM
12-09-2002 11:14 AM
Re: Monitor script running time
Along with "time" and "timex" as suggested above, there is an env. variable called SECONDS that tells you how long the shell has been active. So if you are developing a script, you can do something like this.
#!/usr/bin/ksh
START_TIME=$SECONDS
...
(Your code here)
...
END_TIME=$SECONDS
(( ELAPSED_TIME = END_TIME - START_TIME ))
echo elapsed time is $ELAPSED_TIME
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2002 12:38 PM
12-09-2002 12:38 PM
Re: Monitor script running time
If you are using the korn or posix shell, you can simpley check the value of $SECONDS at the end of the script. This is a built in variable that starts at zero when the script starts.
In the last line of your script, put:
echo "Script ran for $SECONDS seconds"
Tom