当我通过命令行运行命令时,它运行正常,我在附加的* .txt文件中获得了带有所需结果的电子邮件。但是,当cron运行同样的命令时,我收到一个EOF错误。
有人能指出可能导致此错误的原因吗?
我在CentOS上使用Cloudlinux 6.6运行CPanel
以下是我从cron收到的电子邮件中说的错误;
Subject: Cron <root@whm> find /home/accountname/public_html -type f -mtime -7 2> `date +'
/bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 1: syntax error: unexpected end of file
这是我的命令;
01 * * * * find /home/accountname/public_html -type f -mtime -7 2> `date +'%m-%d-%Y'`-accountname-filescan.txt | uuencode `date +'%m-%d-%Y'`-accountname-filescan.txt | mail -s "`date +'%m-%d-%Y'`-accountname File Scan Report" root
我很欣赏任何关于我做错事的建设性意见。
我按照这个线程来发展我的命令; Linux cron job to email output from a command
答案 0 :(得分:1)
你必须逃脱%:
man (5) crontab:
Percent-signs (%) in the command, unless escaped with backslash (\),
will be changed into newline characters, and all data after the
first % will be sent to the command as standard input.