Create a startup script


To allow you to auto start a server service in Linux you need to create several files.

I forgot how to search for this post, so I have included what I would search for in order for maybe this to get to the top of Google one day. The question I Googled was How to create a Linux service.

 

Since I first wrote this I have learned a lot more about Bash script and therefore here is the mark 2 version.

Create two files and don’t forget to use chmod 755 on them to make this executable

server-stop
server-stop

#!/bin/sh
# chkconfig: 235 99 10
# description: Start or stop the XXXXXX server
#
### BEGIN INIT INFO
# Provides:
# Required-Start: $network $syslog
# Required-Stop: $network
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Description: Start or stop the pure-ftp server
### END INIT INFO

start=path to the start script
stop=path to the stop script

name=’what the server name is’

case “$1″ in
‘start’)
$start >/dev/null 2>&1 </dev/null
;;
‘stop’)
$stop
;;

‘restart’)
$stop ; $start
;;
*)
echo “Usage: $0 { start | stop }”
;;
esac
exit

Save the file and then make the file executable

chmod 755 xxxxxx

To start the service manually

service xxxxxx start

To stop the service manually

service xxxxxx stop

To make the serever auto start then issue the following command

chkconfig –levels 345 xxxxxxxx on

OK that is the theory see the list for examples

pure-ftp start stop

glassfish

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s