命令对照
| SysV 用法 | systemd 对应 |
|---|---|
| service nginx start | systemctl start nginx |
| chkconfig nginx on | systemctl enable nginx |
| chkconfig --list | systemctl list-unit-files --type=service |
| /etc/init.d/nginx status | systemctl status nginx |
| chkconfig --add myapp(注册脚本) | 脚本放 /etc/init.d/ 后 daemon-reload 自动生成单元 |
示例
示例
service nginx status
systemctl status nginx --no-pager
systemctl list-unit-files --type=service | grep -i nginxsystemd-sysv-generator 仅为 /etc/init.d 下带 LSB 头的脚本生成单元;长期维护建议直接写原生 .service。