gibney.org
:
Technology
:
Linux
:
Capture Processes
(Entry Nr. 339, by user 1 |
edit
)
Here is an example for php processes: <br> <br><span class=span_content_bash>while :; do ps -eo "%p %x %a"|grep [b]in/php;sleep 0.5; done</span> <br> <br>Here is a more luxurious version, that prefixes each line with the current time and logs the output to a file: <br> <br><span class=span_content_bash><pre>while sleep 1; do ps -eo "%p %x %a"|awk '/bin\/php/ {system("printf %s\\ $(date +\"%Y-%m-%d_%H:%M:%S\")");print}';done | tee -a processes.txt</pre></span> <br> <br>In the last one, please be aware that there are 2 whitespaces after "%s\\". The command will fail, if there is only one.
Create a new entry at this position