后台守护运行提示nohup: ignoring input and appending output to `nohup.out’

在搭建gogs时想要它后台运行。nohup ./gogs web
提示:nohup: ignoring input and appending output to nohup.out’ 意思是 :忽略输入并将输出附加到nohup.out’

程序也能正常启动。

如果不想看到这个提示可以使用如下三种方式:

1、nohup sh xxx.sh >a.log 2>& 1 &
2、nohup sh xxx.sh &>a.log &
# 如果不想输入到a.log 可以使用
3、nohup sh xxx.sh >/dev/null 2>& 1 & 

其中:

nohup放到命令开头表示不挂起,表示即使退出终端该进程也不会掉, & 放在命令到结尾,表示后台运行

  • /dev/null 表示空设备文件 (位桶(bit bucket)或者黑洞(black hole)的地方)
  • 0 表示stdin标准输入
  • 1 表示stdout标准输出
  • 2 表示stderr标准错误
  • 2>&1表示将错误输出重定向到标准输出,注意>& 不能分开
posted @ 2022-12-12 11:38  xunm  阅读(10994)  评论(0)    收藏  举报