Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash: Putting a comment in commandline parameters

Tags:

bash

I have a RHEL machine that I run many processes on. A lot of the processes may have equivalent start parameters, so from top and ps they are identical in this category and cannot be identified from one another.

How could I name or tag a process in its parameters so I can identify one from another? Aside from doing this in bash, how would I do this for a Java process or screen session?

like image 529
hexacyanide Avatar asked Aug 05 '12 01:08

hexacyanide


1 Answers

The canonical way to do this would be to obtain the process id with $!. That way you don't tag the process, but you have an id that uniquely identifies it. For example:

gedit & gedit1=$!

This starts gedit and saves the process id in the variable gedit1. If I want to kill the process later. I can just write

kill $gedit1
like image 51
Kim Stebel Avatar answered Oct 25 '22 01:10

Kim Stebel