What Operating System and version are you running?
I assume from the error message that /bin/sh is a link to bash on your system.
I don't think that "top" is suitable for this exercise because of the amount of irrelevant screen control characters etc. you will get. The formatted output from "top" is unsuitable for processing in unix Shell.
Really needs to use the "ps" command (not "top") combined with some base logic to decide if the process is rogue.
In general, never issue "kill -9" unless you are having trouble shutting a system down. Certainly never issue "kill -9" to a database process while the database is up.
Btw. The first script contains an error (wrong sort of quotes) but this does not mean that the script will work:
i run that script on another i had, on crontab each 5 min checks if the load is bigguer than X then execute that script and email me server info, hostname and uptime,
thank you very much!!!
CTRL+X
---------- Post updated at 01:32 PM ---------- Previous update was at 01:30 PM ----------
Just beware that top, even with the b option, use a right formatted output for the pid ... that's why the awk command may fail of the pid is below 10000 (and I suggested the cut way, I'm no friend with awk :))!