orphan ksh in top output ?
Hi Friends - I am trying to write a script that would check for orphan ksh processes from top command and alert the team.
Here is the sample output of top with Linux flavor more topCPU.log %CPU %MEM VSZ RSS USER STIME PID COMMAND 0.0 0.0 10372 560 root Jun10 1 init [5] 0.0 0.0 0 0 root Jun10 2 [migration/0] 0.0 0.0 0 0 mega Jun10 3 ksh 0.0 0.0 0 0 appuser Jun10 4 -ksh 0.0 0.0 0 0 root Jun10 5 -ksh I wrote a snippet that would basically outputs the entry Example: => more topCPU.log | awk '{print $8}' | grep "^-ksh$" -ksh -ksh How could I get entire line ? OR any better approach ? Thanks |
Code:
\ps -o ppid,args -C -ksh|awk '{if ($1 == 1) {print }}' Code:
pgrep -P 1 -f -- "-ksh" |
Hi UnSpawn -thanks for your reply
I dont want to find out through ps/pgrep commands, coz we have several hosts and end up running several instances of script Just want to grep from log files which have entries of ksh processes |
Code:
more topCPU.log Desired output: 0.0 0.0 0 0 user Jun10 3 ksh 0.0 0.0 0 0 mega Jun10 7 ksh Any help is appreciated Thank you |
Try grep -e ' -\?ksh$' topCPU.log.
|
well, no luck
|
What do you mean, no output? You copy/pasted it when executing?
|
yeah, there is no output
Code:
: |
Code:
'-\?ksh$' topCPU.log Try this one too if it doesn't work as the shell might parse it differently. Code:
grep -e " -\\?ksh$" topCPU.log |
Hello - I tried with and without space earlier, as mentioned it was not able to find the entries in the log file
Tried with double quotes too, no output :-( |
Try these variations as well:
Code:
grep -e " -?ksh$" topCPU.log Code:
echo grep -e " -\\?ksh *$" topCPU.log |
Thanks alot, it worked
All the 3 below commands were giving expected output Code:
grep -e "[[:blank:]]-\\?ksh[[:blank:]]*$" topCPU.log |
All times are GMT -5. The time now is 11:29 AM. |