LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Linux ps output (https://www.linuxquestions.org/questions/linux-newbie-8/linux-ps-output-4175591195/)

smunir362 10-11-2016 12:10 PM

Linux ps output
 
I use following command.
ps -aef|grep frmweb >> frmweb.txt
Actually I want to store output in continuous manner.
like whenever a new frmweb process created save in file...

How can i do that.

rtmistler 10-11-2016 12:26 PM

Brute force is that you can write a script with a delay which performs that ps command and keeps things up to date.

Is frmweb a standard binary, or your own binary? Note that processes created have their process ID stored in the /proc file system.

It would help to understand what your real intentions are if they are beyond monitoring. For instance if you wish to kill all existing processes at some point, or some other thing you wish to do.

Turbocapitalist 10-11-2016 02:43 PM

"watch" can do that

Code:

watch -n 2 -t "ps -aef | grep frmweb >> frmweb.txt"

BW-userx 10-12-2016 07:49 AM

something like this
Code:



if [pgrep -u $USER frmweb ] ; then
 "ps -aef | grep frmweb >> frmweb.log"
fi

check to see if frmweb is running first, if yes log it, not tested. slap it into a job for minutes or if daily then shell script add to cron.daily make executable.

ondoho 10-12-2016 03:04 PM

the ps command is very powerful.
i know for a fact that you can save the "|grep frmweb" by reading "man ps".
maybe it even has an option for continuous output?


All times are GMT -5. The time now is 05:24 PM.