温馨提示×

Linux中nohup启动不输出日志怎么解决

小亿
273
2024-01-26 21:04:45
栏目: 智能运维

在Linux中,使用nohup命令启动后台进程时,输出会被重定向到nohup.out文件中。如果需要查看实时日志,可以通过以下方式解决:

  1. 使用tail命令实时查看日志:

    tail -f nohup.out
    
  2. 将nohup命令的输出重定向到其他文件,并通过tail命令查看:

    nohup command > logfile &
    tail -f logfile
    
  3. 使用tee命令将输出同时重定向到文件和标准输出:

    nohup command | tee logfile
    
  4. 在nohup命令中使用输出重定向符号将输出重定向到/dev/null,这样输出将被丢弃:

    nohup command > /dev/null &
    

请根据实际需求选择合适的方法。

0