i have a java based web application and using Apache server.
once centos reboots java process not running again even existing java process killing and for that i created a script to start apache, cassandra and java process. apche server and cassandra starting but java not starting
for debugging i added echos in my script and appending echo to a file and am able to see the all echo's.
i tried these changes:
API_start.sh in /root path
#!/bin/bash
echo '111111' >> /root/temp.txt
service cassandra start
service httpd start
echo '2222222' >> /root/temp.txt
prid=$(ps aux| egrep '[A]PI_Controller.jar' | awk '{print $2}')
echo $prid >> /root/temp.txt
if [ -z "$prid" ]
then
echo "No process to kill"
else
kill -9 $prid
echo "Successfully service stopped"
fi
echo '33333333' >> /root/temp.txt
pridold=$(ps aux| egrep '[B]lacklist.jar' | awk '{print $2}')
echo $pridold >> /root/temp.txt
if [ -z "$pridold" ]
then
echo "No process to kill"
else
kill -9 $pridold
echo "Successfully service stopped old jar file"
fi
echo '444444444' >> /root/temp.txt
nohup java -Djsse.enableSNIExtension=false -jar API_Controller.jar &
echo '5555555555' >> /root/temp.txt
echo "Successfully service started"
/etc/rc.local file (changed to execute mode)
#!/bin/bash
touch /var/lock/subsys/local
nohup sh /root/API_start.sh &
after rebooting centos i got prints like below in temp.txt
111111
2222222
33333333
444444444
5555555555
if i run API_start.sh manually from /etc/ java able to staring but i need to do it automatically.
please help me where i am doing wrong since i am new to shell script
Thank you