If you want the PID of the process running in screen, I answered that in another question on Stack Overflow. Here is the contents of that answer:
You can get the PID of the screen sessions here like so:
$ screen -ls
There are screens on:
1934.foo_Server (01/25/15 15:26:01) (Detached)
1876.foo_Webserver (01/25/15 15:25:37) (Detached)
1814.foo_Monitor (01/25/15 15:25:13) (Detached)
3 Sockets in /var/run/screen/S-ubuntu.
Let us suppose that you want the PID of the program running in Bash in the foo_Monitor
screen session. Use the PID of the foo_Monitor
screen session to get the PID of the bash
session running in it by searching PPIDs (Parent PID) for the known PID:
$ ps -el | grep 1814 | grep bash
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
0 S 1000 1815 1814 0 80 0 - 5520 wait pts/1 00:00:00 bash
Now get just the PID of the bash
session:
$ ps -el | grep 1814 | grep bash | awk '{print $4}'
1815
Now we want the process with that PID. Just nest the commands, and this time use the -v
flag on grep bash
to get the process that is not bash:
echo $(ps -el | grep $(ps -el | grep 1814 | grep bash | awk '{print $4}') | grep -v bash | awk '{print $4}')
23869
Just replace 1814 with the real PID of your screen session:
echo $(ps -el | grep $(ps -el | grep SCREEN_SESSION_PID | grep bash | awk '{print $4}') | grep -v bash | awk '{print $4}')
pgrep -u ircc -f quassel-core