Ho uno script di shell con i metodi status()
e start()
. Il codice è qui sotto:Script di shell per verificare se il processo è già in esecuzione e uscita se sì
#function to check the jmeter processes running
status(){
PID=$(ps -ef | grep jmeter|grep -v grep)
echo "The jmeter processes running are: \n$PID"
}
#function to run the .jmx file given by the user at run time
start(){
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 &
}
while [ "$1" != "" ]; do
case "$1" in
start)
jmeter_start
;;
status)
jmeter_status
;;
*)
echo $"Usage: $0 {start|status}"
exit 1
esac
shift
done
ora quando ho eseguito questo script, devo verificare se è già in esecuzione e se è in esecuzione devo uscire. Fammi sapere come fare questo.
casi in cui è questo controllo in atto? Nella funzione 'start'? – RowlandB
'start' non viene eseguito in background; inizia un processo diverso in background quindi esiste immediatamente. – chepner
@RowlandB Questo è quello che stavo cercando di implementare ma non potevo farlo – sai