2022-11-08 遇到的一點小問題
最近做某個功能查文檔,剛好看到systemctl 中文手冊和journalctl 中文手冊,記錄兩個個之前沒用到的功能供屉。
systemctl try-restart systemd-timesyncd
有啟動才重啟,否則不重啟泽论。和restart
不一樣韩脏。
之前都是systemctl status systemd-timesyncd > /dev/null 2>&1;echo $?
,判斷0 -eq $?``restart
才重啟脉让。
systemctl cat systemd-timesyncd
直接查看服務(wù)文件
之前都是systemctl status systemd-timesyncd
,從信息里獲取路徑晌杰,再cat讀取cat /usr/lib/systemd/system/systemd-timesyncd.service
跷睦。
.
systemctl daemon-reload
測試的時候經(jīng)常會修改服務(wù)文件,修改完要執(zhí)行systemctl daemon-reload
再restart
肋演。經(jīng)常忘了怎么拼抑诸,順便記錄一下。
echo "$(systemctl status systemd-timesyncd)"
之前的固件惋啃,在控制臺執(zhí)行命令systemctl status systemd-timesyncd
哼鬓,能看到的信息比較多:
最新的固件监右,只能看到一點點信息:
不過還好使用echo能看到比較多的信息边灭,輸出信息里有中文,使用這個也能正常在控制臺顯示健盒。
[root@wannoo ~]# echo "$(systemctl status systemd-timesyncd)"
* systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/usr/lib/systemd/system/systemd-timesyncd.service; disabled; preset: enabled)
Active: active (running) since Thu 2023-03-23 03:14:18 UTC; 35min ago
Docs: man:systemd-timesyncd.service(8)
Main PID: 1028477 (systemd-timesyn)
Status: "Contacted time server 185.209.85.222:123 (pool.ntp.org)."
Tasks: 2 (limit: 4563)
Memory: 1.0M
CGroup: /system.slice/systemd-timesyncd.service
`-1028477 /usr/lib/systemd/systemd-timesyncd
Mar 23 03:14:18 wannoo systemd[1]: Starting Network Time Synchronization...
Mar 23 03:14:18 wannoo systemd[1]: Started Network Time Synchronization.
Mar 23 03:14:18 wannoo systemd-timesyncd[1028477]: Contacted time server 185.209.85.222:123 (pool.ntp.org).
Mar 23 03:14:18 wannoo systemd-timesyncd[1028477]: Initial clock synchronization to Thu 2023-03-23 03:14:18.801809 UTC.
[root@wannoo ~]#