【发布时间】:2016-02-03 03:21:45
【问题描述】:
我从本地机器运行了以下命令:
ssh -i key remote_host "nohup sh test.sh > nohup.out 2> nohup.err < /dev/null &"
然后我得到错误:sudo: sorry, you must have a tty to run sudo
我添加了-tt 选项:
ssh -tt -i key remote_host "nohup sh test.sh > nohup.out 2> nohup.err < /dev/null &"
我检查了遥控器,test.sh 没有运行(没有进程 ID)。
我取出nohup,一切正常,ssh -tt -i key remote_host "sh test.sh" 但我需要使用nohup。有人能帮我吗?非常感谢!
一个remote_host:test.sh脚本:
#!/bin/bash
sudo iptables -A OUTPUT -p tcp --dport 443 -j DROP
sleep 30
sudo iptables -D OUTPUT -p tcp --dport 443 -j DROP
【问题讨论】:
-
可能更适合服务器故障论坛。
-
我使用 -i 密钥文件来 ssh,它不会要求我输入密码。
标签: bash