我在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个文件。
任何想法都存在问题?
感谢。