08-18-2004, 12:53 PM | #1 (permalink) |
Junkie
Location: RI
|
[Linux]Anyone know where I can get a program called pidof?
I'm trying to write a script that'll check if a process is running. I searched around on the net for one and i found a php script that seems to work, but it requires a command called pidof. I've searched around but I haven't been able to find it yet so I figured I'd ask. Thanks.
|
08-18-2004, 12:59 PM | #2 (permalink) |
Junkie
Location: RI
|
Arg, nm this. I musta fat-fingered it and typed in the wrong thing. I found it on RPMFind.net. For those interested, it along with some other tools are at http://rpmfind.net/linux/rpm2html/se...hp?query=pidof
This'll be a fun update..prollay more then likely gonna break somethin. Last edited by Fallon; 08-18-2004 at 01:02 PM.. |
08-18-2004, 01:05 PM | #3 (permalink) |
Professional Loafer
Location: texas
|
Should probably be on the cd of the distribution you used.
__________________
"You hear the one about the fella who died, went to the pearly gates? St. Peter let him in. Sees a guy in a suit making a closing argument. Says, "Who's that?" St. Peter says, "Oh, that's God. Thinks he's Denny Crane." |
08-18-2004, 01:32 PM | #4 (permalink) | |
paranoid
Location: The Netherlands
|
Quote:
I don't know wether you have access to the script you're trying to detect, or it's pid file, but if I were to write both, I'd use a pid file => a pid file, is a file at a specified location (that you can check) that has the pid (process identifier) of the script that is running. Checking the file gives you the pid. Probably lot's of situations where this solution won't fly, but I thought I'd drop the idea anyway
__________________
"Do not kill. Do not rape. Do not steal. These are principles which every man of every faith can embrace. " - Murphy MacManus (Boondock Saints) |
|
08-18-2004, 04:58 PM | #5 (permalink) |
Upright
|
how about: "ps -ef | grep <processID or processname>" imbedded into the code. If no lines returned, then you can be pretty sure that it ain't runnin'. I have run into situations where I needed to know not if a process was running, but rather how many instances were running. For that I shell scripted "ps -ef | grep <processID or processname> | wc -l".
Maybe a bit off track, but I hope it helps. |
08-18-2004, 05:43 PM | #6 (permalink) |
Loser
Location: RPI, Troy, NY
|
Code:
$ ls -l /sbin/pidof lrwxrwxrwx 1 root root 8 May 6 2003 /sbin/pidof -> killall5 if you already have killall5 (ls /sbin/killall5) you can just link it with Code:
# ln -s /sbin/killall5 /sbin/pidof |
08-18-2004, 07:22 PM | #7 (permalink) | |
Junkie
Location: RI
|
Quote:
Thank you a bunch and thank you to everyone else who offered other solutions. |
|
08-19-2004, 12:15 AM | #8 (permalink) | |
In Your Dreams
Location: City of Lights
|
Quote:
Code:
latch@afx:~$ ps -ef | grep tomato latch 24337 24325 0 18:12 pts/457 00:00:00 grep tomato latch@afx:~$ ps -ef | grep proccessIDorprocessName | grep -v grep Then you can pipe to wc -l or whatever you'd like hehe. Code:
latch@afx:~$ ps -ef | grep bash latch 8370 1 0 Aug12 ? 00:00:00 /bin/bash /usr/bin/thunderbird latch 25518 1 0 Aug14 ? 00:00:00 /bin/bash ./restartScript latch 24020 1 0 17:59 ? 00:00:00 /bin/bash /usr/bin/firefox latch 24325 24323 0 18:12 pts/457 00:00:00 -bash latch 24434 24325 0 18:15 pts/457 00:00:00 grep bash latch@afx:~$ ps -ef | grep bash | grep -v grep latch 8370 1 0 Aug12 ? 00:00:00 /bin/bash /usr/bin/thunderbird latch 25518 1 0 Aug14 ? 00:00:00 /bin/bash ./restartScript latch 24020 1 0 17:59 ? 00:00:00 /bin/bash /usr/bin/firefox latch 24325 24323 0 18:12 pts/457 00:00:00 -bash latch@afx:~$ ps -ef | grep bash | grep -v grep | wc -l 4 latch@afx:~$ |
|
08-19-2004, 05:15 AM | #9 (permalink) |
Crazy
|
use a script like this:
#!/bin/sh proc=${1} if [ -z ${proc} ]; then echo "usage: $0 process_name"; exit 1; fi ps ax | awk "\$5 ~ /$proc/ { print \$0 }" Alternatively, use "print \$1" instead of the final "print \$0" to print only the actual PID. Last edited by roboshark; 08-19-2004 at 07:47 AM.. |
08-21-2004, 06:51 PM | #13 (permalink) | |
Upright
|
Quote:
|
|
Tags |
called, linuxanyone, pidof, program |
|
|