Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

crontab entry

Status
Not open for further replies.

nix45

MIS
Nov 21, 2002
478
US
root's crontab looks something like this...

SHELL=/bin/bash
MAILTO=root
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
rsync=/usr/bin/rsync -e ssh -azv --delete --delete-excluded --exclude=/some/folder root@serverA::home /home/

7 */2 * * * $rsync > /root/rsync_`/bin/date +%m%d`"_"`/bin/date +%Tp`.txt

The problem is redirecting the output to the above file name. If I manually run that command from the shell, it works fine and creates a file called something like /root/rsync_1009_00:58:09p.txt. When I run it from a cron job, it fails and the job doesn't run. This is the error...

/bin/bash: -c: line 1: unexpected EOF while looking for matching ``'
/bin/bash: -c: line 2: syntax error: unexpected end of file

If I do a simple redirect without the date command, it works fine. For example, $rsync > somefile.txt works no problem from cron.

Thanks,
Chris
 
..got it working, cron was interpretting the % as a newline, so each % had to be escaped.

7 */2 * * * $rsync > /root/rsync_`/bin/date +\%m\%d_\%I\%M\%p` 2>&1

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top