Hi,
I'm fairly new to scripting in Unix. However, I am trying to write a script that checks running Oracle report processes and kills the processes if the CPU time is greater than 500. Here is my script:
#!/usr/bin/ksh93
count=$(ps -ef|grep oracle.reports|grep -v 'grep'|wc -l) # get count of number of oracle report processes
for num in $count; do # set up loop
proc_num=$(ps -ef|grep oracle.reports|grep -v 'grep'|awk '{print $2}') # get process number
proc_time=$(ps -ef|grep oracle.reports|grep -v 'grep'|awk '{print $7}'|sed 's/://') # get process CPU time, covert to five digit number
if [[ $proc_time -ge 50000 ]]
then
kill $proc_num
fi
done
The output to my script is this:
32174 52636 73406 80108
000 048 003 000
./report_mon: line 11: .
000
048
003
000: arithmetic syntax error.
Anyone know what the problem is? Am I not constructing the loop properly?
Thanks in advance!
I'm fairly new to scripting in Unix. However, I am trying to write a script that checks running Oracle report processes and kills the processes if the CPU time is greater than 500. Here is my script:
#!/usr/bin/ksh93
count=$(ps -ef|grep oracle.reports|grep -v 'grep'|wc -l) # get count of number of oracle report processes
for num in $count; do # set up loop
proc_num=$(ps -ef|grep oracle.reports|grep -v 'grep'|awk '{print $2}') # get process number
proc_time=$(ps -ef|grep oracle.reports|grep -v 'grep'|awk '{print $7}'|sed 's/://') # get process CPU time, covert to five digit number
if [[ $proc_time -ge 50000 ]]
then
kill $proc_num
fi
done
The output to my script is this:
32174 52636 73406 80108
000 048 003 000
./report_mon: line 11: .
000
048
003
000: arithmetic syntax error.
Anyone know what the problem is? Am I not constructing the loop properly?
Thanks in advance!