【发布时间】:2016-03-27 10:36:57
【问题描述】:
我有一些脚本正在 vm 上开发,但有时需要在生产服务器上运行才能正确测试。
我需要脚本的输出进行调试,因此我将以下解决方案组合在一起:
function test_remote() {
scp $1 Prod:/home/xxx/tmp/
n=${1:t:r}
f=${1:t}
cmd="ssh Prod \"/usr/bin/php /home/xxx/tmp/$f\" > /home/xxx/tests/$n-remote-test.html"
eval ${cmd}
ssh Prod "rm /home/xxx/tmp/$f"
echo "done"
}
我已放在我的 .zshrc 文件中
我想使用
在后台运行它test_remote path_to_file/php_file.php &
但我总是得到以下结果
[1] + 12996 suspended (tty input) test_remote path_to_file/php_file.php
如果我用 bg 恢复它,它只会重复相同的消息
【问题讨论】:
-
在调用
test_remote或cmd时使用</dev/null重定向stdin 是否有效? -
在这两种情况下都可以!如果您不介意,最好在帖子中进行一些解释,以便我可以将其标记为正确答案