Showing posts with label process. Show all posts
Showing posts with label process. Show all posts

Oct 12, 2013

Find out current working directory of a running process?

pwdx <PID>
lsof -p <PID> | grep cwd
readlink -e /proc/<PID>/cwd

Jul 4, 2013

I want to know when a running process will terminate. How can I watch it?

http://askubuntu.com/questions/313138/i-want-to-know-when-a-running-process-will-terminate-how-can-i-watch-it
while [ -d /proc/ ]; do sleep 1; done; echo "Process finished at $(date +"%F %T")."
Or you can make a bash script:
#!/bin/bash

if [ ! -d /proc/$1 ]; then
    echo "Process $1 doesn't exist."
    exit 1
fi

while [ -d /proc/$1 ]; do
    sleep 1
done

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