Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time it takes a command to run

Status
Not open for further replies.

Eddiefdz

IS-IT--Management
Mar 20, 2002
273
US
Hello,

Can you guys tell me of an easy way of telling how long it took a program to run. For example, i have cron job that runs a script that I run every night to do backups. I want to know how long it takes the backups to finish. So what is the best way to go about doing this?

Thanks,

Eddie Fernandez
CCNA, Network+, A+, MCP
 
Why not take the time you start your cron job from the time your log ends as in ls -ltr <logfile> (assuming you have a log)? Voila - the total time for the backup.
 
Since it's a script, you could just put a 'date' at the beginning and the end, that will tell you when it started and stopped. Alternatively, if there is a single command that runs the backups in the script, put 'time' in front of it.

Code:
ns1(~)$ time sleep 5

real    0m5.009s
user    0m0.000s
sys     0m0.002s

real is wall clock time, user and sys tell the time the process spent doing work in use and kernel space, respectively.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top