Rani
Rani

Reputation: 401

track PID of a background process and store it along with the process name in linux

i want to save the PID of a background process and save it to a file along with the process name in linux. What is the command to do so? Can anybody help me out?

Upvotes: 1

Views: 412

Answers (1)

kmkaplan
kmkaplan

Reputation: 18960

I am not sure what you call the “process name” but in Bourne shells you get the PID of a background process with the shell variable $!. For example:

sleep 1000 &
echo "$! sleep 1000" >>/tmp/save_file.txt

Upvotes: 1

Related Questions