ps -ef | grep "a file in the system"

hi,

how do i ps -ef | grep "a file in the system"?

we have a process that we store the PID on a file so it can be monitored. but the procedure is to cat "a file in the system" and then what ever is the content of the file, i will ps -ef|grep PID.

Thanks in advance,
Itik

i am not able to get your question correctly,

but i would assume that you need to search a process in the running process list, and the process id has to fetched from a file

let the file containing the process id be ProcessIdList

ps -ef | grep -f ProcessIdList

please try to see man grep or man some_command before you ask about some_command

Best Regards,
Rakesh UV

I think he's asking about file existence, I'll take for example "/var/run/sshd.pid" where the SSHD pid is stored.
I can check what is this file with :

file /var/run/sshd.pid

or get stats for the file :

stat /var/run/sshd.pid

look at fuser and lsof, too.

here's an example that I do:

root$> cd /process/stat

root$> cat process_save_pid
123456

root$>ps -ef|grep 123456

***********
***********

I want to simplify the three commands in one.

Is that possible?

Thanks in advance,
itik

ps -fp `cat /process/stat/process_save_pid`

Cool!

Thanks!