I have a shell script to run JMeter test. Script generates the Jmeter log out put and creates sar (suppose to create sar file though it does not). Shell script is -
runtest()
{
export JMETER_HOME=/home/software/apache-jmeter-2.6
host=$1
port=$2
loopcount=$3
logfile=jmeter$(date -d "today" +"%Y%m%d%H%M%S").jtl
sarfile=sar$(date -d "today" +"%Y%m%d%H%M%S").dat
sar -o $sar_file 3 100000 >/dev/null 2>&1 &
sar_pid=$!;
echo 'sar started with pid' $sar_pid;
for ((start=1; start <= $loopcount; start++ ))
do
echo 'Iteration' $start;
$JMETER_HOME/bin/jmeter.sh -n -t ReportWebService.jmx -Jhost=$host -Jport=$port -l $logfile
done
sleep 2
echo 'killing sar process id' $sar_pid
kill -9 $sar_pid;
}
runtest localhost 8087 1
When I execute the shell script, I eventually encounter error -
sar started with pid 13191
Iteration 1
Created the tree successfully using ReportWebService.jmx
Starting the test @ Tue Apr 17 11:16:24 IST 2012 (1334641584914)
Waiting for possible shutdown message on port 4445
Tidying up ... @ Tue Apr 17 11:16:25 IST 2012 (1334641585129)
... end of run
killing sar process id 13191
./temp.sh: line 22: kill: (13191) - No such process
And I don't see any ".dat" file generated for sar data. What is wrong with this shell script? Please be gentle, I am new to world of Unix.

sarcommand has evidently terminated by the time you get around tokilling it. You should be investigating yoursarcommand to see if it is working correctly. Try running the exact command outside the script. In addition, check your script for typos. In particular, your question has a typo: you setsarfilebut usesar_file. Use a consistent variable naming scheme and check your original script to see if that typo exists. – jw013 Apr 17 '12 at 6:28