Pretty new to Centos 7 and most of my earlier experiences were with Ubuntu. I have just set up an application on Centos 7 and I saw on their product website that to run the application as a Linux Service (Start at System Startup), this is the script that one needs to use.
#! /bin/sh
export JAVA_HOME="/usr/lib/jvm/jdk1.7.0_07"
startcmd='<PRODUCT_HOME>/bin/listener_mm.sh start > /dev/null &'
restartcmd='<PRODUCT_HOME>/bin/listener_mm.sh restart > /dev/null &'
stopcmd='<PRODUCT_HOME>/bin/listener_mm.sh stop > /dev/null &'
case "$1" in
start)
echo "Starting the Listener Server ..."
su -c "${startcmd}" user1
;;
restart)
echo "Re-starting the Listener Server ..."
su -c "${restartcmd}" user1
;;
stop)
echo "Stopping the Listener Server ..."
su -c "${stopcmd}" user1
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
Haha hope esac is not specific to other distro :?
So I created the script, substituted the correct values as per my enviroment, and added a Symbolic link to my script. I have couple of questions 1) The above script is perhaps for Ubuntu or another Linux Distro. So do I need to make any changes to the script? 2) How do I make this run as a service , for all users? I would want this to start at System Startup. Debian / Ubuntu has update-rc.d, and I guess i need to use chkconfig for this. Can I have any pointers on this? It happens to be a machine with few other things, so I am a little vary of experimenting and if anyone with experience on this could give me some pointers, it will be great.
I am doing some reading on systemd but any help will be really appreciated.
Thanks a ton.
Cheers, M.M