Find the answer to your Linux question:
Results 1 to 2 of 2
Hallo... I need to run this script to protect the user1 from more than 30% cpu usage.But kill is not working within awk.What should I do ?? #!/bin/bash ps -fuU ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2005
    Posts
    14

    kill command is not working within awk


    Hallo...
    I need to run this script to protect the user1 from more than 30% cpu usage.But kill is not working within awk.What should I do ??

    #!/bin/bash

    ps -fuU user1 >> psFile

    awk '{ if( $3 > "30")
    kill -9 $2 }' psFile
    rm psFile

    Help me.Thank u.

  2. #2
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    Of course it's not working , kill is not an awk command ! Either use system
    which IS an awk command or have it print the kill command and pipe
    that to the shell.
    For details you can look in the gawk manual on the gnu website.

    By the way are you sure you want to "protect" the user from more than
    30% CPU usage ? Any sort of calculation (like using bc) will use more
    than 30%

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •