I would like to know any command that I can run to know the end time of a process.
I have already launched the process and know its PID but I want to know if there is any command that can tell me at what time it ended.
THanks for your help.
13 Answers
Run this:
while kill -0 <PID>; do sleep 1; done; echo "Process finished at $(date +"%F %T")." Or you can make a bash script. wait-for-death.sh:
#!/bin/bash if ! kill -0 $1; then echo "Process $1 doesn't exist." exit 1 fi while kill -0 $1; do sleep 1 done echo "Process $1 finished at $(date +"%F %T")." Then give it execution permission:
chmod +x wait-for-death.sh and run it passing the process' PID:
./wait-for-death.sh <PID> 3If you want to avoid PID collisions you can use at:
job_id=$(at now <<< 'sleep 10' 2>&1 | awk 'END {print $2}') while at -l | grep -q "^${job_id}\s" do sleep 1 done echo "Process finished at $(date)" Maybe the command time fits to your need:
time [options] command [arguments...] Example:
time /local/usr/bin/myProcess arg1 arg2 Once the process finishes time will show some statistics like the time taken to complete the process (in seconds I think).
Check the man page or just take a look to this online man page.
1