niedziela, 29 sierpnia 2010

Fedora: Adding services to the startup sequence

Today I was wondering if there is a utility that allows you to control the services that are loaded at the startup (e.g. I wanted to add vsftpd/sshd/mysqld to the automatic startup sequence). I found a command line utilities: chkconfig and ntsysv. I briefly checked the first (I will describe it later on) but actually used the ntsysv (but it seems that at the end it uses chkconfig to add the service to a current runlevel) to add the startup services - you can see what does it look like on the attached screenshot. If you would like to use the ntsysv for a specific runlevel:

[root@krystianekb init.d]# ntsysv --level 5 -> for runlevel 5
[root@krystianekb init.d]# ntsysv --level 235 -> for runlevels 2,3,5

For a services that come with the Fedora, like vsftpd, mysqld, sshd etc. it is only a matter of marking the service to be started or not started during boot. However I have created my own service (for starting the JBoss), which I was able to control with the service command but it was not seen by the ntsysv and was not compatible with the chkconfig. I found in the man page of chkconfig about one cool feature, namely that one can specify within the service (own script in the init.d directory) for which level this service could be available with what start and stop priorities. So I have added the following line to the top section of my startup script:

# chkconfig: 235 90 15

The first column identifies the runlevels: 2,3,5, second column the start priority: here 90 and the last one the stop priority: here 15. The following sequence of command demonstrates how to add a service for runlevels 2,3,5 and how does the ntsysv and chkconfig work together:

[root@krystianekb init.d]# chkconfig --add jboss
[root@krystianekb init.d]# chkconfig --list jboss
jboss 0:off 1:off 2:off 3:off 4:off 5:off 6:off

[root@krystianekb init.d]# ntsysv --level 235
[root@krystianekb init.d]# chkconfig --list jboss
jboss 0:off 1:off 2:on 3:on 4:off 5:on 6:off

Brak komentarzy:

Prześlij komentarz