Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sure fire way to get a PID

Status
Not open for further replies.

iggystar

IS-IT--Management
Jul 12, 2001
126
US
I want a PID, just a PID and nothing but a PID.

You'd think ps would have an option for this, but if it does I can't find it.

I've tried piping the results of a PS command into every little unix widget I can think of I can't find a way to get the PID that works every time.

Any suggestions?

I need this so I can write a scripts I need for my rc1.d, rc2.d, etc directories. If anybody can point me to a good FAQ or recommend a good boox for a beginning Linux admin I'd appreciate that as well. I've been underwhelmed by the books I've looked at so far.
 
Well it's in the ballpark, but not exactly. I need the pid of a specific process, not just all the processes.

The line you gave me just gives me all the pids, it's not exactly what I need.
 
How to you identify the process????

Can you explain what you really mean here?

Do you mean that you know the name of the process and want it's pid to kill it? I'd just use killall for that.

Or do you mean the last process you ran? There are shell variables for that sort of thing.

Be more specific as to what you want and I'm sure we can help you. Tony Lawrence
SCO Unix/Linux Resources tony@pcunix.com
 
Hi,

On a redhat system you can just do :

cat /var/run/httpd.pid

(e.g. for the pid of httpd)

This can be used as an argument to something like kill - for example :

kill `cat /var/run/httpd.pid`

(all the .pids are in /var/run )

Hope this helps

 
how about something like:

ps ax -o pid -o cmd | g sshd | cut -f1 -d\/

this gives me a list of the pids for the sshd process(es) running on my machine... AV
tnedor@yahoo.com

Did this post help? Click below to let me know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top