yes it is working fine please let me know below syntax
2..Also if you can add to send alert massage with running job name more then 10 time with their process ID,Will be fine
Basically the -o switch to ps allows you to select your own fields rather than use the defaults. This is particularly important in writing scripts that may be transferred to another platform, because the default selection of fields in ps -efwill be different if you move from Linux to Unix or MacOS X but ps -o will, with Yoda's caveats, most likely work. And if they don't, you will get an error rather than some odd misbehaviour that is hard to trace.
Multiple fields can be specified using a comma to separate each from the next. For instance, the default fields given by
on my Ubuntu system are equivalent to
but if I wanted the parent-pid and effective user-id instead of the tty and the time I could type
And by changing the order of the field names you change their order in the output.
Appending the equals sign (=) to a field name suppresses its heading in the final output. Note, though, that you have to suppress the heading of every field, for example:
ps -opid=,ppid=,args= # right
ps -opid,ppid,args= # wrong, will only suppress the COMMAND heading
I hope that makes sense.
Getting the PIDs of the processes in the alert could be more tricky. If you use my original suggestion and have pgrep on your system you could use pgrep within the loop to inject the PIDs into your message.
Sure, you can add another -o pid= column, and you can change -o comm= to -o args=
Rule: put the predictable columns first, and have the args last!
ps -u abcd -o pid= -o args=
The trailing = means "don't print a header for this column", and all columns = means "don't print a header line at all".
apmcd47 mentioned a shorter notation but I found it does not work everywhere.
Does it look more promising now?
Postprocessing of args is problematic because it contains spaces. In awk you cannot simply refer to column $2 because your process name might be in $3...