Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a new service in linux enterprise

Status
Not open for further replies.

Helmsley

Programmer
Dec 17, 2001
18
0
0
SG
Hi, I've developed a java application which i would like to enable as a linux service. so when i execute the command "service <my_application> start", it will be started as a service. I understand that I have to have a perl script in /etc/rc.d/init.d to do that, which I have already written. However, when I start up the service, it does not seem to be running.

I posted the script here. Can anyone help me look through it to see wat is wrong with it? Thanks

#!/bin/bash
#
# processname: msgfwd
#chkconfig: - 91 35

# source function library
. /etc/init.d/functions

RETVAL=0
prog="msgfwd"

start() {
export DISPLAY=10.10.10.192:0.0
echo -n $"Starting Message Forwarder: "
# The following line is to start my application
/MF/MF_v1.0/run_mf
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/msgfwd
return $RETVAL
}

stop() {
echo -n $"Shutting down Message Forwarder: "
# The following command is a script is to stop my application
/home/ckahmun/MF_v1.0/kill_mf
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/msgfwd
return $RETVAL
}


restart() {
stop
start
}


case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
;;
condrestart)
stop
start
;;
status)
# what do i add here?

;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac

exit $?
 
You need a bash script, not a perl script.

Also
Code:
#chkconfig:  - 91 35

Should have a space after the first asterisk character



D.E.R. Management - IT Project Management Consulting
 
oh yes, my mistake. its a bash script. but is there anything wrong with my script at all?
 
Make sure your script knows about $JAVA_HOME or equivalent if it is not defined elsewhere.

On a side note, you can issue

[tt][navy]ps ax | grep java[/navy][/tt]

to list all java processes and verify it is running.

Lorenzo Wacondo (System Administrator)

## Just because you can do something doesn't mean you should.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top