Listing 1
This one usually works. It correctly determines if
/etc/cron is running.
ps -fu root | grep /etc/cron
root 641 1 0 22:23:00 ? 0:00 /etc/cron
This one never works. The sleep 2 simulates a heavily
loaded system, causing grep always to find at least
one "/etc/cron" in the ps output.
( sleep 2 ; ps -fu root ) | grep /etc/cron
root 641 1 0 22:23:00 ? 0:00 /etc/cron
root 221 1 0 22:36:25 01 0:00 grep /etc/cron
|