运行 systemctl status 或 service status 后如何不等待输入 / 输出。

2020-04-05 09:38:31 +08:00
 jmyz0455

在使用 sudo systemctl status ***sudo service *** status 这样的命令时,打印出来的通常都会处于等待输入或输出的状态,类似这样:

● nginx.service - The NGINX HTTP and reverse proxy server
   Loaded: loaded (/etc/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2020-03-31 18:38:55 CST; 4 days ago
 Main PID: 23306 (nginx)
    Tasks: 4 (limit: 1078)
   Memory: 11.3M
   CGroup: /system.slice/nginx.service
           ├─23306 nginx: master process /etc/nginx/sbin/nginx -c /etc/nginx/conf/nginx.conf
           ├─23307 nginx: worker process
           ├─23308 nginx: worker process
           └─23309 nginx: worker process

Mar 31 18:38:55 vps systemd[1]: Starting The NGINX HTTP and reverse proxy server...
Mar 31 18:38:55 vps nginx[23304]: nginx: the configuration file /etc/nginx/conf/nginx.conf syntax i
Mar 31 18:38:55 vps nginx[23304]: nginx: configuration file /etc/nginx/conf/nginx.conf test is succ
Mar 31 18:38:55 vps systemd[1]: nginx.service: Failed to parse PID from file /etc/nginx/logs/nginx.
Mar 31 18:38:55 vps systemd[1]: Started The NGINX HTTP and reverse proxy server.

然后终端一直在等待输出的状态(不知道怎么形容),需要按 q 才能退出(也不知道怎么形容普通的模式叫啥,有没有老铁科普下?),我的系统是 Ubuntu 19.10 。

请问有能一次输出不需要按任何键才能退出的方法吗?看过 help 貌似没有一次性输出这种参数。

3228 次点击
所在节点    Linux
4 条回复
darrh00
2020-04-05 09:48:16 +08:00
--no-pager
Do not pipe output into a pager.
jmyz0455
2020-04-05 09:57:21 +08:00
@darrh00 感谢🙏
julyclyde
2020-04-05 16:23:54 +08:00
@darrh00 请教,是什么设置使它进入了 pager 状态,以至于需要用 no pager 来抑制呢?
darrh00
2020-04-05 17:02:12 +08:00
@julyclyde

手册里都有写,设置 SYSTEMD_PAGER=cat 和使用--no-pager 的效果是一样的。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/659530

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX