In fact, you already have most. You should be able to use the code from status , which receives the PID and just checks to see if it exists. If so, print some error and exit. Otherwise, do what you already have.
start(){ PID=$(ps -ef | grep jmeter|grep -v grep) if [ -z $PID ]; then echo "Error: JMeter already running" exit fi echo "Please enter the file name .jmx extension" read file echo "Please enter the log file name .jtl extension" read log_file sh /home/ubuntu/apache-jmeter-3.0/bin/jmeter.sh -n -t $file -l $log_file &
}
source share