
本文共 3302 字,大约阅读时间需要 11 分钟。
������ctl������������������
������������ctl������������
���Linux������������������ctl���systemctl������������������������������������������systemd���������systemctl���������������`/usr/lib/systemd/`������������������������������������������������
- 1���/usr/lib/systemd/system������������������������������������������������������������������������������������������init���������
- 2���/usr/lib/systemd/user������������������������������������������������������������������������������
������ctl���������������������
- 1���*.service������������������������������������������������������������
- 2���*.target���������������������������������������������������������������
���systemd������������������������������������������������
- Type���������������������������������������`forking`���������`simple`���`oneshot`���`dbus`���`notify`���`idle`������������
- EnvironmentFile������������������������������������������������-������������������������������������`Environment=-/path/to/config`���������������������������������������
- KillMode���������������������������������������������������������`control-group`���������`process`���`mixed`���`none`������
- Restart���������������������������������������`no`���������`on-failure`���`on-abort`������
- ExecStart���`ExecReload`���������������������������������������������������������������������������������
- PrivateTmp���������������������������������������������
������[Install]������������������������������������������`WantedBy=multi-user.target`���
������������������������������������`*.service`���������������`systemctl daemon-reload`���systemd���������������������
������������������
������������systemctl���������������������������������������Nginx���������������ctl���������������
#!/bin/bashcase $1 instart) systemctl start nginx check_status nginx ;;stop) systemctl stop nginx check_status nginx ;;reload) systemctl reload nginx check_status nginx ;;status) check_status nginx ;;*) echo "Usage: $0 {start|stop|reload|status}" exit 1esac
������������������`check_status`������������������������������������������������������������������������
```bash chmod +x nginx.sh ```������������������������������������
```bash systemctl enable nginx ```���������������/usr/lib/systemd/system/nginx.service������
```ini [Unit] Description=Nginx������[Service] Type=forking ExecStart=/usr/local/nginx/bin/nginx ExecStop=/usr/local/nginx/bin/nginx stopping PrivateTmp=true
[Install] WantedBy=multi-user.target
���������������������
```bashsystemctl start nginxsystemctl status nginx
������������ctl������������������
1.���������������
```bash systemctl start # ������������ systemctl stop # ������������ systemctl restart # ������������������ systemctl reload # ������������������������ systemctl status # ������������������ ```2.���������������
```bash systemctl enable # ������������������������������ systemctl disable # ��������������������������� ```3.���������������
```bash systemctl list-unit-files # ������������������������������������ systemctl disable --now # ������������������ systemctl kill # ������������������������������������ ```���������������������������������������Linux������������systemd���������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
