back to this How do I find the PID of the last open file in terminal?
I want to know the PPID (parent id of the process) of the last executed process.
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityback to this How do I find the PID of the last open file in terminal?
I want to know the PPID (parent id of the process) of the last executed process.
This question is ambiguous: are you asking for how to get the PPID of the last process executed in a Terminal or are you asking for how to get the PPID of the last process executed doing so via the Terminal?
If the first one, either I'm missing something or the PPID of the last process executed in the current Terminal's current inner bash
instance is the current Terminal's current inner bash
instance PID, which is always stored in $
:
echo $$
If the second one you can run:
ps -e --sort -start_time -o ppid | head -5 | tail -1
In a terminal run this command:
<your_command> &
awk '{print $4}' "/proc/$\!/stat"
e.g.
$ gedit &
[1] 12130
$ awk '{print $4}' "/proc/$\!/stat"
11099
$ ps xa | grep 11099
11099 pts/0 Ss 0:01 /usr/bin/zsh
bash
instance PID, i.e. e.g.echo $$
?