【发布时间】:2013-01-11 10:17:41
【问题描述】:
我的脚本在提示符下运行良好,但在 crontab 下运行良好。唯一被破坏的是脚本的子shell中忽略的here文档。该脚本使用 psftp。代码如下:
/home/batch/myscript.sh:
(
cd /home/downloaded/csv/
psftp -pw passw0rd -P 1234 user@someftp.com << EOF
cd outgoing
mget *.csv
EOF
) | tee /home/batch/logs/mylog.log | mail -s "Mail subject" "me@mycompany.com"
crontab -e:
45 10 * * * /bin/sh /home/batch/myscript.sh
确定 - 从提示符启动时发送邮件:
Remote working directory is /
psftp> Remote directory is now /outgoing
psftp> *.csv: nothing matched
psftp> quit
KO - 从 crontab 启动时的邮件:
Remote working directory is /
psftp> quit
Google 没有提供很多帮助。我尝试了几种 EOF 语法,因为这似乎是这里文档的常见问题,但我认为它不是来自这个。它可能与 crontab 的某种嵌套级别有关,有这样的事情吗?
最好的问候
【问题讨论】:
-
尝试删除
<<之后的空格? -
@tripleee 我只是尝试删除空间,它并没有改变问题。 crontab KO,提示确定。