1. You need to create a script file inside of
1 |
/etc/init.d/SCRIPT_NAME_kutayzorlu |
We will add this script to chkconfig
1 |
chkconfig --add SCRIPT_NAME_kutayzorlu |
After list the CHKconfig LIST
1 2 |
[root@kutayzorlu ~]# chkconfig --list SCRIPT_NAME_kutayzorlu SCRIPT_NAME_kutayzorlu 0:off 1:off 2:off 3:on 4:on 5:on 6:off |
Start the service
1 2 |
[root@kutayzorlu ~]# service SCRIPT_NAME_kutayzorlu start [ OK ] |
Example Init Script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
#!/bin/bash # # /etc/rc.d/init.d/<servicename> # # <description of the *service*> # <any general comments about this init script> # # <tags -- see below for tag definitions. *Every line* from the top # of the file to the end of the tags section must begin with a # # character. After the tags section, there should be a blank line. # This keeps normal comments in the rest of the file from being # mistaken for tags, should they happen to fit the pattern.> # Source function library. . /etc/init.d/functions <define any local shell functions used by the code that follows> start() { echo -n "Starting <servicename>: " <start daemons, perhaps with the daemon function> touch /var/lock/subsys/<servicename> return <return code of starting daemon> } stop() { echo -n "Shutting down <servicename>: " <stop daemons, perhaps with the killproc function> rm -f /var/lock/subsys/<servicename> return <return code of stopping daemon> } case "$1" in start) start ;; stop) stop ;; status) <report the status of the daemons in free-form format, perhaps with the status function> ;; restart) stop start ;; reload) <cause the service configuration to be reread, either with kill -HUP or by restarting the daemons, in a manner similar to restart above> ;; condrestart) <Restarts the servce if it is already running. For example:> [ -f /var/lock/subsys/<service> ] && restart || : probe) <optional. If it exists, then it should determine whether or not the service needs to be restarted or reloaded (or whatever) in order to activate any changes in the configuration scripts. It should print out a list of commands to give to $0; see the description under the probe tag below.> ;; *) echo "Usage: <servicename> {start|stop|status|reload|restart[|probe]" exit 1 ;; esac exit $? |
#===================================================================
Other Method , Soon :__)