Skip to main content
added 177 characters in body
Source Link
Hackaholic
  • 2.2k
  • 1
  • 12
  • 11

using awk:

ps aux --sort=-%cpu | awk 'NR==1{print $0$2,$3,$11}NR>1{if($3!=0.0) print $0$2,$3,$11}' > some_file.txt

the above code will give all program with non-zero cpu usage.
will give you pid,%cpu, command_name

if you want cpu usage greater than equal to 60 replace $3!=0.0 to $3>=60

I have saved the output in file some_file.txt. you can cat the file and pipe it to mail command.

try like this: to send mail

cat some_file.txt | mailx -r "[email protected]" -s "SUBJECT" "[email protected]"

using awk:

ps aux --sort=-%cpu | awk 'NR==1{print $0}NR>1{if($3!=0.0) print $0}'

the above code will give all program with non-zero cpu usage.

if you want cpu usage greater than equal to 60 replace $3!=0.0 to $3>=60

using awk:

ps aux --sort=-%cpu | awk 'NR==1{print $2,$3,$11}NR>1{if($3!=0.0) print $2,$3,$11}' > some_file.txt

the above code will give all program with non-zero cpu usage.
will give you pid,%cpu, command_name

if you want cpu usage greater than equal to 60 replace $3!=0.0 to $3>=60

I have saved the output in file some_file.txt. you can cat the file and pipe it to mail command.

try like this: to send mail

cat some_file.txt | mailx -r "[email protected]" -s "SUBJECT" "[email protected]"
Source Link
Hackaholic
  • 2.2k
  • 1
  • 12
  • 11

using awk:

ps aux --sort=-%cpu | awk 'NR==1{print $0}NR>1{if($3!=0.0) print $0}'

the above code will give all program with non-zero cpu usage.

if you want cpu usage greater than equal to 60 replace $3!=0.0 to $3>=60