
Systemd 常用命令
systemctl
systemctl start/stop/restart/status/cat
:用于服务管理 systemctl enable/disable/is-enable
:设置服务自启动 systemctl daemon-reload :重新加载 systemd 管理的配置文件
journalctl
- journalctl -u
[options1] [options2] - -u :查询指定service的日志
- optinons1
- –no-pager :日志不分页(默认分页)
- –since [time]:查询从指定时间段开始的日志,time 的日期格式如下(时间解析时默认使用本时区而非utc,可以使用–utc指定为utc时区)
- 绝对日期(可省略部分):“YYYY-MM-DD HH:MM:SS”
- 相对时间格式:“now”,“today”,“yesterday”,“tomorrow” 等
- –until [time]:查询到指定时间点结束的日志
- optins2
- -f :呈现实时日志
- -n [num]: 查询最近num条日志