- 编写需要执行的shell脚本
脚本规范:
- 第一行(#!/bin/sh),指定解释器
- 第二行(#chkconfig: 2345 80 90),表示在2/3/4/5运行级别启动,启动序号(S80),关闭序号(K90)
redis
#!/bin/sh#chkconfig: 2345 80 90/home/cluster/redis-5.0.5/src/redis-server /home/cluster/redis-5.0.5/redis-cluster/6379/redis.conf/home/cluster/redis-5.0.5/src/redis-server /home/cluster/redis-5.0.5/redis-cluster/6380/redis.conf
nacos
#!/bin/sh#chkconfig: 2345 80 90# 环境变量export PATH=$PATH:/home/jdk1.8.0_172/bin/home/nacos/bin/startup.sh
keepalived
复制脚本至系统目录下
cp ***.sh /etc/init.d
脚本授权可执行
chmod +x ***.sh
将脚本加入开机启动项中
chkconfig --add ***.sh
查看日志 ```bash journalctl -u *
systemctl status *
6. 常用命令```shell# 启动服务systemctl start postfix.service# 关闭服务systemctl stop postfix.service# 重启服务systemctl restart postfix.service# 显示服务的状态systemctl status postfix.service管理服务自启动# 在开机时启用服务systemctl enable postfix.service# 在开机时禁用服务systemctl disable postfix.service# 查看服务是否开机启动systemctl is-enabled postfix.service# 查看开机自启动的服务列表systemctl list-unit-files | grep enabled# 查看启动失败的服务列表systemctl --failed
