Actively watching for running processes

Here's a fun one...

What's the best way to script looking for a process when it runs? For example, what if a process is running that's been set up graphically, which you would like the entire command line string for? Say it's rpm for the sake of having a command to use as an example. You want to know what some utility is running with 'rpm -options'. How can you do a 'ps aux | grep rpm' and have it watch actively for an extended period of time for the command to occur?

:slight_smile:

do it in a loop?

while true
do
ps -aux | grep rpm | grep -v grep
sleep 1
done

Thats a basic idea, but you can elaborate with logging to a file for example.

That works wonderfully. Thank you very much. :slight_smile:

takes the simple piece of code and make it unecessarily long and redudant :wink: