- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: time it takes to complete script
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
Discussions
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
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
01-27-2004 03:19 PM
01-27-2004 03:19 PM
Right now in my script I have...
echo "Such and such started at `date`"
I would also like it to at the end state
echo "It took ?? minutes to complete this process"
One more thing, I would also like to add...
The size of the file is ?? MB or GB. How do you convert an ls -l on a file?
Is ls -l in HP 11.00 showing it in kb, then I would times by 1024? for mb?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2004 03:40 PM
01-27-2004 03:40 PM
SolutionIf you want the time to be calculated within the script, you can use the built-in variable "SECONDS".
start=$SECONDS
your_script..
..
..
end=$SECONDS
(( TIME = ( $end - $seconds ) / 60 ))
echo "Time it took is $TIME minutes approximately"
Actually the size you get in ls -l is in bytes. You will need to devide it by 1048576 (1024*1024) to get it in MB.
SIZE=$(ls -al file|awk '{print $5/1048576}')
echo "size is $SIZE
TO calculate the size of a file, I would do the following
SIZE=$(du -sk file|awk '{print $1/1024}')
echo "Size of the file is $SIZE MB"
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2004 03:42 PM
01-27-2004 03:42 PM
Re: time it takes to complete script
I should have added. From externally you can use the command timex while running the script to get the total time it took.
timex your_script
real 0.02
user 0.01
sys 0.01
YOu should see something like the above. real is the real time it took. user is the time cpu spent to run the program in user mode and sys is the time cpu spent to run in kernel mode.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2004 03:54 PM
01-27-2004 03:54 PM
Re: time it takes to complete script
#ls -l show the size in bytes.
#du -ak can show the figures in Kbytes.
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2004 08:19 PM
01-27-2004 08:19 PM
Re: time it takes to complete script
ll "$*" | awk '
function sv(val)
{
pv=sprintf("%3.3fKb",val/1024.0);
if (val>=1048576.0) pv=sprintf("%3.3fMb",val/1048576.0);
if (val>=1073741824.0) pv=sprintf("%3.3fGb",val/1073741824.0);
return pv;
}
{
if($1~"d.")
printf("%10s %-5d %9s %9s %3s %-2s %5s %s\n",$1,$2,$3,$4,$6,$7,$8,$9);
else printf("%10s %-5d %9s %9s %10s %3s %-2s %5s %s\n",$1,$2,$3,$4,sv($5),$6,$7,$8,$9);
}'