Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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'm starting the same process multiple times and using the process ID to differentiate between them for future control. How would I go about getting back the process ID for the process I just started? Is it possible to append some sort of command to the command used to start the process?

share|improve this question

If you are using a Bash script, here's what you can do:

gedit &
echo $! > /tmp/
sleep 5
kill -15 $(cat /tmp/

This is just an example running gedit (text editor), saving its PID (Process ID) and killing it after 5 seconds using its PID and signal 15 (TERM).

share|improve this answer

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.