chkconfig 命令
使用chkconfig 或者 chkconfig –list就可以看出当前系统已经设置的各个服务在各个运行级别下的开闭状态
[root@VM-0-14-centos /]# chkconfig servicename on/off
[root@VM-0-14-centos /]# chkconfig --list
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
bt 0:off 1:off 2:on 3:on 4:on 5:on 6:off
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
php-fpm-56 0:off 1:off 2:on 3:on 4:on 5:on 6:off
php-fpm-70 0:off 1:off 2:on 3:on 4:on 5:on 6:off
php-fpm-72 0:off 1:off 2:on 3:on 4:on 5:on 6:off
php-fpm-80 0:off 1:off 2:on 3:on 4:on 5:on 6:off
pure-ftpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
redis 0:off 1:off 2:on 3:on 4:on 5:on 6:off
添加到chkconfig
[root@VM-0-14-centos /]# chkconfig add php-fpm-80
[root@VM-0-14-centos /]# chkconfig php-fpm-80 on
[root@VM-0-14-centos /]# chkconfig --list
php-fpm-80 0:off 1:off 2:on 3:on 4:on 5:on 6:off
2-5都开启证明服务会跟随系统启动
方法2修改/etc/rc.d/rc.local这个文件
[root@VM-0-14-centos /]# vi /etc/rc.d/rc.local
!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
/usr/local/qcloud/irq/net_smp_affinity.sh >/tmp/net_affinity.log 2>&1
/usr/local/qcloud/cpuidle/cpuidle_support.sh &> /tmp/cpuidle_support.log
/usr/local/qcloud/rps/set_rps.sh >/tmp/setRps.log 2>&1
/usr/local/qcloud/irq/virtio_blk_smp_affinity.sh > /tmp/virtio_blk_affinity.log 2>&1
/usr/local/qcloud/gpu/nv_gpu_conf.sh >/tmp/nv_gpu_conf.log 2>&1
将启动的路径加进去
列如:
/usr/local/nginx/sbin/nginx