In this blog, you will come to know the process of Adding services to auto start after reboot in Linux.
chkconfig – Updates and queries runlevel information for system services.
SYNOPSIS
# chkconfig --list service_name
The chkconfig command can also be used to activate and deactivate services. The chkconfig –list command displays a list of system services and whether they are started (on) or stopped (off) in runlevels 0-6. At the end of the list is a section for the services managed by xinetd.
$ chkconfig --list | sort | less auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off ...
Check the mysqld,zabbix-agent and httpd service is auto-started in below mention runlevel:
[root@node1 sshinde]# chkconfig --list acpid 0:off 1:off 2:on 3:on 4:on 5:on 6:off atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off mysqld 0:off 1:off 2:on 3:on 4:off 5:on 6:off sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off zabbix-agent 0:off 1:off 2:off 3:off 4:off 5:off 6:off ...
[root@node1 sshinde]# chkconfig --level 235 zabbix-agent on [root@node1 sshinde]# chkconfig --level 235 httpd on [root@node1 sshinde]# chkconfig --level 235 mysqld on [root@node1 sshinde]# chkconfig --list acpid 0:off 1:off 2:on 3:on 4:on 5:on 6:off atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off httpd 0:off 1:off 2:on 3:on 4:off 5:on 6:off mysqld 0:off 1:off 2:on 3:on 4:off 5:on 6:off sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off zabbix-agent 0:off 1:off 2:on 3:on 4:off 5:on 6:off ... [root@node1 sshinde]#
To Disable any run-level use the off parameter.
[root@node1 sshinde]# chkconfig --level 2 mysqld off //In run-level 2 (init 2) mysqld service will not auto start
# chkconfig --del httpd # chkconfig --list | grep httpd //verify the settings
- Whenever you add or remove a service from chkconfig control, it does the following under the /etc/rc.d sub-directories.
- When chkconfig –add command is executed, it creates a symbolic link file to start and stop the service under corresponding rc directory.
- When chkconfig –del command is executed, it removes the symbolic link file from the corresponding rc directory.
End of the tutorial, Adding services to auto start after reboot in Linux.
Thanks for reading this article, you’ll also like:
Checklist for Pre and Post Linux Reboot
How to install Nginx in RHEL and CentOS
How to Setup Alerting System for Graphite Metrics
How to execute script or command on reboot or startup in Linux