Capture kill command execution
Posted on 2011-02-21
In a Bash script, I have to set a condition as shown. The script should execute kill command (with signal 15) to kill a Process ID. Based on the successful killing of process ID, the script should report the user. What I observed is, when I issue an kill command, regardless of process ID gets killed or not, am getting the EXIT status (captured with variable RETVAL) as ZERO. Please let me know how can I capture the status of PID gets killed or not.
kill -15 "$JBOSSPID"
if [ "$RETVAL" == "0" ]; then
echo "Admin Application has been stopped" && echo
rm -rf /var/lock/subsys/admin
echo "$CURRENT_TIME: Admin application has been stopped." >> $LOGFILE
echo "Couldn't stop Jboss process. Please check it manually." && echo