我试图让 systemd 做 init.d 脚本会做的事情,在手动给出启动或停止命令后自动显示服务的状态。这有可能吗?
不幸的是,systemd 会立即弹出,因为它在后台运行,然后您必须执行第二个命令来显示状态,启动或停止可能有效,也可能无效,除非您询问并让您幸福地无知,否则 systemd 不会告诉您。
IE。我想得到
service nginx status
在我做完之后自动运行
service nginx start
或者
service nginx restart
(或在大脑受损的 systemd 中, systemctl start nginx.service)