Systemctl commonly used commands
Set boot
systemctl enable apache.service
Immediately start a service
$ sudo systemctl start apache.service
Stop a service immediately
$ sudo systemctl stop apache.service
Restart a service
$ sudo systemctl restart apache.service
Killing a child processes all services
$ sudo systemctl kill apache.service
Reload a service profile
$ sudo systemctl reload apache.service
Reload all modified configuration files
$ sudo systemctl daemon-reload
Display all of a Unit
$ systemctl show httpd.service
Value of the specified property of a Unit
$ systemctl show -p CPUShares httpd.service
Sets the specified property of a Unit
$ sudo systemctl set-property httpd.service CPUShares=500
Output profile status message list, there are four states:
- enabled: Start link has been established
- disabled: No link established start
- static: The profile was not [Install] section (not performed), as the only other dependent configuration file
- masked: The configuration file is prohibited to establish links start
$ systemctl list-unit-files
Once modify the configuration file, you need to let Systemd reload the configuration file, then restart to take effect.
$ sudo systemctl daemon-reload
$ sudo systemctl restart httpd.service
Journal
Systemd unified management of all the Unit's log, so we can easily use a journalctl
command you can view all logs
View all logs
$ sudo journalctl
Show the last n lines of the log tail
$ sudo journalctl -n
View logs specified process
$ sudo journalctl _PID=1
Script view a log path
$ sudo journalctl /usr/bin/bash
Real-time scrolling display the latest log
$ sudo journalctl -f
The latest real-time scrolling display a log of Unit
$ sudo journalctl -u nginx.service -f
See specified priority (level and above) log, a total of eight
0: emerg
. 1: Alert
2: Crit
. 3: ERR
. 4: warning
. 5: Notice
. 6: info
. 7: Debug
$ sudo journalctl -p err -b
Author: tingshuo123
link: https: //www.jianshu.com/p/36150c09838b
Source: Jane books
are copyrighted by the author. Commercial reprint please contact the author authorized, non-commercial reprint please indicate the source.