How to check if a process id (PID) exists
In a bash script, I want to do the following (in pseudo-code): if [ a process exists with $PID ]; then kill $PID fi What’s the appropriate expression for the conditional statement? 11 Answers 11
In a bash script, I want to do the following (in pseudo-code): if [ a process exists with $PID ]; then kill $PID fi What’s the appropriate expression for the conditional statement? 11 Answers 11
I recently come across a file with the extension .pid and explored inside it but didn’t find much. The documentation says: A Pid-File is a file containing the process identification number (pid) that is stored in a well-defined location of the filesystem thus allowing other programs to find out the pid of a running script. … Read more
How do I get the id of my Java process? I know there are several platform-dependent hacks, but I would prefer a more generic solution. 22 Answers 22
I am trying to use port 80 for my application server, but when I perform netstat -aon I get: TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4 When I look up the process in task manager, it shows PID 4 is SYSTEM, that’s it. No extension… nothing. Just “SYSTEM“. What’s going on here? I’m afraid to end this … Read more
I start a background process from my shell script, and I would like to kill this process when my script finishes. How to get the PID of this process from my shell script? As far as I can see variable $! contains the PID of the current script, not the background process. 8 Answers 8 … Read more