I'm trying to figure out when a command I entered stopped executing, for example
sudo apt-get update
I want information like:
started execution at : 12:00
finished execution at : 12:15
I'm trying to figure out when a command I entered stopped executing, for example
sudo apt-get update
I want information like:
started execution at : 12:00
finished execution at : 12:15
Key point that should be understood about processes is that their metadata is not logged by default. You can, however, obtain certain information while process runs.
As has been stated in related StackOverflow question in wlk's answer, start time can be obtained via
-o
flag tops
andltime
format specifier:Stop time, however, is not tracked by the system usually, so that's something you'll have to track yourself. Knowing PID of a process, you could poll for that PID existence, and echo the timestamp when it disappears
See also: https://stackoverflow.com/a/5207048/3701431
How about writing our own bash script?
Save the script as
logscript.sh
Make it executable by using
chmod +x logscript.sh
You can run 'command' using
./logscript.sh command
For example,
./logscript.sh sudo apt-get update
Check this site for interesting time-display formats.