Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I am new babe to Linux. So please skip to read if you are not patient with begineer.

Let's say I am asked to check and shut down the processes that I am not familiar with. So when I ls under bin folder, I see multiple process .sh. But I want to know which process is associated with which tomcat process.

Is there any easy way to find out that?

Example, but when I do ps -ef | grep startmyprocess1 doesn't return the running process.

But actually the running tomcat process name is myprocess, so when I do ps -ef | grep myprocess, I can see the running process. To know that I have to ask the responsible person.

So, the names are different. If like that, I need to ask him several times. Any better way to figure this out?

share|improve this question
I'm not sure what you are really asking for here.. What do you mean by 'checking'? If you want to grep the name of the script use ps l | grep startmyprocess1. – user13742 Jul 16 '12 at 11:08
For the process you figured out you can try if grep myprocess gives you some pointers. If the scripts are build by the same person, it is very likely you can find the same line in the other scripts too. – jippie Jul 16 '12 at 18:20
hi all, for my case, I only know script. but I don't know that script is running for the process myprocess. How can I know is running for myprocess? – kitokid Jul 17 '12 at 1:44

5 Answers 5

try this one..,(not tested)

ps -aux | grep "yourprocess"

For example,

ps -aux | grep "httpd"
share|improve this answer

Starting myprocess from within does not name the process after the underlying shell script, that is why your ps -ef | grep startmyprocess1 does not return a result.

This is also why many processes, especially daemons, write their pid out to file so that you can easily reference it's process. This can be done with:

echo $pid > /tmp/

or you can query $! which contains the last pid:

echo $! > /tmp/

and query/list the process by it's pid:

ps --pid $PID
share|improve this answer

I think software like "top" will done great work.




share|improve this answer

Try the following approach

ps -ef | grep

Fetch the Parent PID for, then use below command to find out the parent process from it's PID.

ps -ef | grep *PPID*
share|improve this answer

Answer from @invert has explained a lot, shell script just executes commands within it. What's that means is, you won't get your shell script name at output of top or htop, which just prints the /proc/$PID/cmdline of each routine within the shell script.

Besides using echo $! after command to get the PID of what you want. I'd like to use pgrep command when I need to(or pkill if you would like to kill it).

pgrep, pkill - look up or signal processes based on name and other attributes

The pgrep simply grep your arguments via /proc/*/cmdline and output matching PIDs The pkill is compatiable with kill, so you can easily pkill any routine with the cmdline

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.