Monday, December 19, 2016

Getting PIDs of all instances of a particular script

This perl code finds the PIDs of all instances of a particluar file.

Let's say you have a file /home/user/script and lets say you have 4 multiple instances of it running on your computer at the same time. You want to find the PIDs of all of them. You can use this :

ps -ef | grep your_file_name | grep -v grep | awk '{print $2}'

You'll have all 4 PIDs separated by a new line character.

No comments:

Post a Comment