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

lanisle · 2012年06月06日 · 最后由 lanisle 回复于 2012年06月07日 · 4911 次阅读
/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 关闭了讨论。 01月10日 18:40
需要 登录 后方可回复, 如果你还没有账号请 注册新账号