V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
jmyz0455
V2EX  ›  Linux

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

  •  
  •   jmyz0455 · 2020-04-05 09:38:31 +08:00 · 3226 次点击
    这是一个创建于 1480 天前的主题,其中的信息可能已经有所发展或是发生改变。

    在使用 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 貌似没有一次性输出这种参数。

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

    手册里都有写,设置 SYSTEMD_PAGER=cat 和使用--no-pager 的效果是一样的。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3329 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 11:45 · PVG 19:45 · LAX 04:45 · JFK 07:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.