Forums

Pidof does not work

I am trying to get PID with process name (e. myprocess) using pidof in bash console, but it does not wok. I used this to change my process name in my python script: setproctitle.setproctitle("somerandomname"), when I use pidof -s somerandomname I get nothing. I also tried PID=$(ps aux | grep "/home/artembakhanov/script.py" | awk '{print $2}'), but I got an error: Error, do this: mount -t proc proc /proc. How can I get PID? Thanks!

You could use python and do a os.getpid().

Also keep in mind that your processes may not be all running on the same server (so they might not be able to see other processes that you have running)