Tuesday, February 19, 2008

Timing background jobs to a file

If you are running a lengthy simulation or a compilation, sometimes you might have to close/logout of your terminal. However, if you just use the "time" command with out redirecting it is output to a file, you will not see the output of time command. For example you run a job and left terminal like following:

$>time ./my_job > my_job_output &

This will run "my_job" in the background and send its output to "my_job_output". If you do leave your terminal open, you will see your run time information on the terminal screen. However, if you close your terminal window, you will not see this information since your strerr is now not available.
For this purpose, you can send your program output and time output to different files. Then, even if you close your terminal, you will still see your time command output:

$> (time ./my_job >my_job_output) >& time.out &

This way you will run your job in the background, see your time command output and you can close your terminal.

No comments: