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?

closed as off-topic by Milliways, Steve Robillard, joan, Ingo, Ghanima Sep 24 '18 at 11:21

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be specific to the Raspberry Pi within the scope defined in the help center." – Milliways, Steve Robillard, joan, Ingo, Ghanima
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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 '18 at 20:41

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.