当我用crontab运行这个shell脚本时,它不起作用但如果我手动操作,如果有效。
我缺少一个要配置的环境变量,或者需要做一些额外的工作才能使其工作。
谢谢你的帮助。
脚本:/process/files/test_expect_cron.sh
remoteuser="user"
remotehost="10.77.88.111"
remotepass="pass1"
cd /process/files
pathfiles="/process/files"
remote_files="/data/20201129/*FILES_20201129*"
cat > expect.dat << EOF
spawn scp -r $remoteuser@$remotehost:$remote_files $pathfiles/.
expect "*?assword*"
send "$remotepassr"
interact
EOF
expect "expect.dat"
Crontab
40 11 * * * sh /process/files/test_expect_cron.sh
我找到的解决方案是更改
interact
至
expect eof
exit
如果有人有更好的解决方案,请张贴