[英]ssh from crontab returning 'tcgetattr: Invalid argument'
I'm defining something like this in my crontab
: 我在我的
crontab
定义了类似的东西:
* * * * * ssh -tt otherhost whoami
And I'm getting the following output: 我得到以下输出:
tcgetattr: Invalid argument
me
Running ssh
with fewer -tt
options leads to other errors besides tcgetattr
. 使用较少的
-tt
选项运行ssh
会导致除tcgetattr
之外的其他错误。
The solution posted in why is the `tcgetattr` error seen when ssh is used for dumping the backup file on another server? 解决了为什么在使用ssh将备份文件转储到另一台服务器上时出现`tcgetattr`错误的解决方案? doesn't really work well because in this case I'm using several
ssh
connections to run monitoring scripts on different hosts and I need to capture output sent to stderr
and email it. 实际上并不是很好,因为在这种情况下我使用几个
ssh
连接在不同的主机上运行监视脚本,我需要捕获发送到stderr
并通过电子邮件发送它。
Any ideas on how to workaround this? 关于如何解决这个问题的任何想法?
You could use something like this: 你可以使用这样的东西:
ssh -tt otherhost "your_monitoring_script 2>&1" 2> /dev/null
That way the errors from ssh go in the bucket, but the errors from your script are shown in stdout. 这样来自ssh的错误就会进入存储桶,但是脚本中的错误会显示在stdout中。 For that to work you should mark errors from your script as "ERROR:" so that you can find them back if your script provides lots of output.
要使其工作,您应该将脚本中的错误标记为“错误:”,以便在脚本提供大量输出时可以找回它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.