简体   繁体   中英

ssh from crontab returning 'tcgetattr: Invalid argument'

I'm defining something like this in my 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 .

The solution posted in why is the `tcgetattr` error seen when ssh is used for dumping the backup file on another server? 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.

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM