Can someone please show me an example of starting a simple background process on the command line; and then later maybe have to open a new command line and then kill the background process?

  • 3
    Your question has nothing to do with Raspberry Pi per se; it's a general Unix/Linux question. It's also very easy to find the answer by googling run process in the background. You'll find hundreds of examples, including this one
    – Seamus
    Sep 15, 2018 at 20:41

1 Answer 1


You can run a process in the background with the & at the end. After you started the process, you can get the process number (pid) with $!. later you can use that process number to kill the process.

sleep 60 &
sleep 2

If you want to use the pid in another shell, you need to save it to a file.

sleep 3600
echo $! > /tmp/pidfile

kill $(cat /tmp/pidfile)

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