We have an email engine in our corporation which is installed in Solaris based machine. It is currently facing delays in transactions. So a temporary work around was deployed that is a cronjob was made for restarting email engine every hour. We tested in lab system and it worked pretty okay but in production it failed. Cronjob executes every hour saying killed but actually the process for email engine do not get killed.
Following is the cron we made for the email engine killing script:
That is by, adding print statement for PID and check whether it gets the correct PID. And the script has the required permissions to kill that process.
The original script contains a syntax error (a space character after PID=) and a logic error because it will kill itself because it's own command line contains the string "AREmail" ! Also I believe that the logfile redirect is in the wrong place.
Maybe try this alternative construct
#!/usr/bin/ksh
SCRIPT_NAME="`basename $0`" # Name of this script
(
ps -eaf | grep "AREmail" | grep -v "grep" | grep -v "${SCRIPT_NAME}" | \
awk '{print $2}' | while read PID
do
echo "killing ${PID}"
# Remove echo when tested
echo "kill -9 ${PID}"
done
) 2>&1 >/opt/remedy/ar/AREmail/email_kill.out