linux - 从 crontab 运行时预期脚本失败,但在手动运行时有效
问题描述
当我使用 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 "$remotepass\r"
interact
EOF
expect "expect.dat"
crontab
40 11 * * * sh /process/files/test_expect_cron.sh
解决方案
我找到的解决方案是改变
interact
至
expect eof
exit
如果有人有更好的解决方案,请发布
推荐阅读
- android - 在 Android 构建上使用 windows 包
- javascript - 当 Emoji 具有肤色时,Javascript 会遍历 Unicode
- vbscript - HTA,VBScript settimeout,更新元素不起作用
- vue.js - 从外部重定向Vue获取道具
- python - 如何为updateview制作表单html
- javascript - 当 console.log 位于函数调用之上时,函数得出正确的结论
- python - Scikit GridSearchCV - fit() 和 predict() 如何与 ColumnTranformers 和 Pipelines 结合使用
- python - 我们如何在没有递归的情况下使用 python lambda 函数计算数字的阶乘
- javascript - Webpack从css加载图像文件两次并损坏
- javascript - 在 TypeScript 中解构箭头函数