Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Interesting question. Anyway, next time you run a command that takes a long time, consider using at (see the manpage: man at). This will queue it as a job, you'll be notified of when it's finished, etc. It's very basic, Cron-like, but for single shots of jobs. – gertvdijk Jun 26 '13 at 22:22

Run this:

while kill -0 <PID>; do sleep 1; done; echo "Process finished at $(date +"%F %T")."

Or you can make a bash script.


if kill -0 $1; then
    echo "Process $1 doesn't exist."
    exit 1

while kill -0 $1; do
    sleep 1

echo "Process $1 finished at $(date +"%F %T")."

Then give it execution permission:

chmod +x

and run it passing the process' PID:

./ <PID>
share|improve this answer
while kill -0 <pid>; do ... is more portable -- it will work on non-Linux systems too. And there's no reason to use bash -- your code doesn't use any bashisms so /bin/sh is perfectly fine here. – Richard Hansen Jul 3 '13 at 21:16
@RichardHansen this site is about Ubuntu, this is not StackOverflow. – hakermania Jul 4 '13 at 13:52
@RichardHansen Thanks for kill -0, I think it's a more elegant solution. – Eric Carvalho Jul 4 '13 at 19:38
@hakermania: I understand, which is why I still gave it +1. I was just pointing out a couple of ways to make the script more portable in case someone wanted to do the same thing on a BSD/Solaris/etc. system. I believe that it's a good idea to stick to POSIX unless there's a reason to do something Ubuntu-specific. In this case, there's no reason to not write a POSIX-conformant script. – Richard Hansen Jul 5 '13 at 4:00

If 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"
    sleep 1
echo "Process finished at $(date)"
share|improve this answer

Maybe the command time fits to your need:

time [options] command [arguments...]


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.

share|improve this answer
OP said he "already launched the process", so time is not an option. – Eric Carvalho Jul 4 '13 at 19:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.