nohup: ignoring input and appending output to ‘nohup.out’

在执行linux命令的时候出现了下面错误:
nohup: ignoring input and appending output to ‘nohup.out’
或者:
nohup: failed to run command `xxx.sh’: Permission denied

一般我们自己写的脚本,想利用nohup命令让脚本程序自己运行,但是nohup他必然会产生日志文件,所以这需要我们将日志文件写到一个文件里面去,默认是写入到nohup.out中,但是有时候会出现上面的问题。

错误原因:
文件没有写入权限。。。
一般就算你用sudo chmod给文件加权限也没用。

解决方法:
 

 nohup ./xxx.sh > /dev/null 2> /dev/null &
 #./xxx.sh 是你自己需要执行的脚本
 # 例如:
 nohup ./bug > /dev/null 2> /dev/null &

这样他会给你输入到 /dev/null 这个特别的文件下面

它像一个linux黑洞,所有重定向到它的信息都会自动消失。

如果你的输入日志很重要的话就不建议重定向到/dev/null中了。

猜你喜欢

转载自blog.csdn.net/BlackPlus28/article/details/88070874