Take the 2-minute tour ×
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 startmyprocess1.sh, 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. –  Herman Torjussen Jul 16 '12 at 11:08
    
For the process you figured out you can try if grep myprocess startmyprocess1.sh 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 startmyprocess1.sh script. but I don't know that script is running for the process myprocess. How can I know startmyprocess1.sh is running for myprocess? –  kitokid Jul 17 '12 at 1:44
add comment

2 Answers

Starting myprocess from within startmyprocess.sh 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:

#!/bin/sh
pid=`myprocess`
echo $pid > /tmp/myprocess.pid

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

#!/bin/sh
myprocess
echo $! > /tmp/myprocess.pid

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

ps --pid $PID
share|improve this answer
add comment

try this one..,(not tested)

ps -aux | grep "yourprocess"

For example,

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

Your Answer

 
discard

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.