![]() |
[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.
|
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. |
Should probably be on the cd of the distribution you used.
|
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 :) |
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. |
Code:
$ ls -l /sbin/pidof if you already have killall5 (ls /sbin/killall5) you can just link it with Code:
# ln -s /sbin/killall5 /sbin/pidof |
Quote:
Thank you a bunch and thank you to everyone else who offered other solutions. |
Quote:
Code:
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 |
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. |
Quote:
|
[jrw@thorin jrw]$ rpm -qf /sbin/pidof
SysVinit-2.84-2 If you are using a redhatish distribution, it'll be in the SysVinit package. |
Quote:
|
Quote:
|
All part of the fun of having total control ;)
|
All times are GMT -8. The time now is 10:51 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project