catch unix process – ps

[problem]

You want to catch a process, but they just shoot by too quickly.

Every time you run a ps, you cannot spot that specific command.

You need a capture script.

[/problem]

[solution]

Run the code at the example and it will catch changing and new processes. To be more aggressive, just change “sleep 5” to “sleep 1”.

[/solution]

[example]

user=”marcus”

ps –fu $user > catchdiff

while :

do

ps -fu $user | diff - catchdiff | egrep -v 'catchdiff|-bash$|^---|^[0-9]'

sleep 5

done

[/example]

[reference]

[tags]ps, diff, egrep, while, process[/tags]

[/reference]

If you have found my website useful, please consider buying me a coffee below 😉

Leave a Reply

Your email address will not be published. Required fields are marked *