Reputation:
How can I get the PID of a TERMINAL running a process with given PID? For example, I open a new terminal and run it a process, say ". / dbserver", then I have the PID of the process using pidof dbServer
, so I want the PID of the terminal that is running dbserver. bash.
Upvotes: 0
Views: 1681
Reputation: 2412
Considering that the Terminal is then that process's parent, see here: https://superuser.com/questions/150117/how-to-get-parent-pid-of-a-given-process-in-gnu-linux-from-command-line
ps -p `pidof dbserver` -o ppid=
Upvotes: 1
Reputation: 225202
The output of ps -f
includes the parent PID of each process. You could also use -o ppid
along with whichever other fields you are interested in.
Upvotes: 1