Linux [SOLVED] 使用 cron 时候有遇到过 stdin: is not a tty error 吗?

lanisle · June 06, 2012 · Last by lanisle replied at June 07, 2012 · 4913 hits
/bin/bash -l -c 'thin restart -C /project/config/thin.yml' > /dev/null

上述语句配置报错了,错误信息就是 stdin: is not a tty error,导致 cron 每隔 1 分钟重复执行命令。。。

另外一个脚本运行得好好的,想不通,搜也搜不到有价值的信息。

/bin/bash -l -c 'backup perform --trigger project' > /dev/null

#1 楼 @diudiutang 谢谢,以及解决了,现在贴下思路。

从你给的链接里尝试了加上-i 参数,但是又引发了问题,原因是自动加载的 dot files 里面针对交互式的 shell 有额外的初始化命令。

静下来思考发现 backup perform 的那条记录也有报同样错误,这下才觉得问题是出在bash -l -c上,所以以"bash -l -c" stdin: is not a tty为关键字搜索得知是 mesg 的问题。

This message is typically generated by programs such as biff or mesg lurking within your remote user’s .profile or .bashrc files (or any other such files, including system-wide ones.) 
#http://docs.fabfile.org/en/1.4.0/faq.html

解决方法,修改~/.profile,将

mesg n

替换为

if `tty -s`;
  mesg n
fi

http://tech.karbassi.com/2011/11/09/stdin-is-not-a-tty/

BTW: 感谢管理员帮我修正了帖子格式,之前没去注意,:)

lanisle closed this topic. 10 Jan 18:40
You need to Sign in before reply, if you don't have an account, please Sign up first.