使用nohup的远程服务器上的ssh - 无法创建文件

时间:2017-08-02 12:04:51

标签: ssh centos7 nohup

我在ssh ssh user@host '/dir/myscript.sh'和myscript.sh上调用远程服务器上的shell脚本然后用nohup运行另一个脚本,但第二个脚本不写入nohup /使用echo "" > test.txt的任何其他文件。

myscript.sh

#!/bin/bash

shopt -s expand_aliases
source /home/user/.bash_profile

nohup /dir/myscript-real.sh > my.out 2> my.err < /dev/null &

myscript-real.sh

#!/bin/bash

shopt -s expand_aliases
source /home/user/.bash_profile

echo -e "test"
sleep 15
echo "2nd test"
echo "test" > test.out
exit

通过SSH运行时 - 没有创建文件(my.out,my.err或test.out),但直接运行myscript.sh时 - 正在创建这3个文件。

任何想法都存在问题?

感谢。

0 个答案:

没有答案