uhhm
uhhm

Reputation: 21

Linux crontab find and email results receiving EOF

when I run a command via command line, it works fine, I get the email with the desired results inside of an attached *.txt file. however, when cron runs this same command, I receive an EOF error.

Can anyone point out what might be causing this error?

I am running CPanel on CentOS with Cloudlinux 6.6

Here is the email I receive from cron saying it errored;

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

Here is my command;

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

I'd appreciate any constructive input on what I am doing wrong.

I followed this thread to develop my command; Linux cron job to email output from a command

Upvotes: 0

Views: 190

Answers (1)

Jose Luis Bernat
Jose Luis Bernat

Reputation: 149

You must escape %:

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.

Upvotes: 1

Related Questions