国产欧美日韩第一页|日本一二三不卡视频|在线精品小视频,亚洲第一免费播放区,metcn人体亚洲一区,亚洲精品午夜视频

systemctl 命令完全指南(三)

2016-12-17 18:23:20 11853

使用Systemctl控制并管理服務


12. 列出所有服務(包括啟用的和禁用的)

# systemctl list-unit-files --type=service
UNIT FILE STATE
arp-ethers.service disabled
auditd.service enabled
autovt@.service disabled
blk-availability.service disabled
brandbot.service static
collectd.service disabled
console-getty.service disabled
console-shell.service disabled
cpupower.service disabled
crond.service enabled
dbus-org.Fedoraproject.FirewallD1.service enabled
....

13. Linux中如何啟動、重啟、停?、重載服務以及檢查服務(如 httpd.service)狀態(tài)

# systemctl start httpd.service
# systemctl restart httpd.service
# systemctl stop httpd.service
# systemctl reload httpd.service
# systemctl status httpd.service
httpd.service -TheApache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
Active: active (running) since Tue2015-04-2817:21:30 IST;6s ago
Process:2876ExecStop=/bin/kill -WINCH ${MAINPID}(code=exited, status=0/SUCCESS)
Main PID:2881(httpd)
Status:"Processing requests..."
CGroup:/system.slice/httpd.service
├─2881/usr/sbin/httpd -DFOREGROUND
├─2884/usr/sbin/httpd -DFOREGROUND
├─2885/usr/sbin/httpd -DFOREGROUND
├─2886/usr/sbin/httpd -DFOREGROUND
├─2887/usr/sbin/httpd -DFOREGROUND
└─2888/usr/sbin/httpd -DFOREGROUND
Apr2817:21:30 tecmint systemd[1]:StartingTheApache HTTP Server...
Apr2817:21:30 tecmint httpd[2881]: AH00558: httpd:Couldnot reliably determine the server's fully q...ssage
Apr 28 17:21:30 tecmint systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.

注意:當我們使用systemctl的start,restart,stop和reload命令時,我們不會從終端獲?到任何輸出內容,只有status命令可以打印輸出。

14. 如何激活服務并在啟動時啟用或禁用服務(即系統(tǒng)啟動時自動啟動服務)

# systemctl is-active httpd.service
# systemctl enable httpd.service
# systemctl disable httpd.service

15. 如何屏蔽(讓它不能啟動)或顯示服務(如 httpd.service)

# systemctl mask httpd.service
ln -s '/dev/null''/etc/systemd/system/httpd.service'
# systemctl unmask httpd.service
rm '/etc/systemd/system/httpd.service'

16. 使用systemctl命令殺死服務

# systemctl kill httpd
# systemctl status httpd
httpd.service -TheApache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
Active: failed (Result:exit-code) since Tue2015-04-2818:01:42 IST;28min ago
Main PID:2881(code=exited, status=0/SUCCESS)
Status:"Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
Apr2817:37:29 tecmint systemd[1]: httpd.service:Got notification message from PID 2881, but recepti...bled.
Apr2817:37:29 tecmint systemd[1]: httpd.service:Got notification message from PID 2881, but recepti...bled.
Apr2817:37:39 tecmint systemd[1]: httpd.service:Got notification message from PID 2881, but recepti...bled.
Apr2817:37:39 tecmint systemd[1]: httpd.service:Got notification message from PID 2881, but recepti...bled.
Apr2817:37:49 tecmint systemd[1]: httpd.service:Got notification message from PID 2881, but recepti...bled.
Apr2817:37:49 tecmint systemd[1]: httpd.service:Got notification message from PID 2881, but recepti...bled.
Apr2817:37:59 tecmint systemd[1]: httpd.service:Got notification message from PID 2881, but recepti...bled.
Apr2817:37:59 tecmint systemd[1]: httpd.service:Got notification message from PID 2881, but recepti...bled.
Apr2818:01:42 tecmint systemd[1]: httpd.service: control process exited, code=exited status=226
Apr2818:01:42 tecmint systemd[1]:Unit httpd.service entered failed state.
Hint:Some lines were ellipsized,use-l to show in full.

提交成功!非常感謝您的反饋,我們會繼續(xù)努力做到更好!

這條文檔是否有幫助解決問題?

非常抱歉未能幫助到您。為了給您提供更好的服務,我們很需要您進一步的反饋信息:

在文檔使用中是否遇到以下問題: