rsync - Command's extra options does not working on cron

leonardokato

Cadet
Joined
May 9, 2019
Messages
2
Hi,
I'm using Rsync to backup PCs in my company but I have problem with extra options:
Code:
--exclude node_modules --log-file=/mnt/xxx/xxx/BackupLogs/backup_9/`date +%Y%m%d`.log

When I start job with this options manually from WebGui, it's running without problems BUT on cron I'm getting error:
Code:
/bin/sh: Syntax error: EOF in backquote substitution
/bin/sh: Syntax error: Error in command substitution

How to resolve this?
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Have you tried double quotes around the entire command?
 

leonardokato

Cadet
Joined
May 9, 2019
Messages
2
Have you tried double quotes around the entire command?
Hi,

Yes, still same error - here is email's subject from one PC:
Code:
Cron <root@DesktopNAS> PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin" /usr/bin/lockf -s -t 0 -k "/mnt/xxx/Backup/Klienci5" /usr/local/bin/rsync -r -t -z --exclude node_modules --log-file="/mnt/xxx/xxx/BackupLogs/backup_5/`date +
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
I don't see how your response corresponds with "double quotes around the entire command".

You don't need them for the paths with no spaces.

If you want me to show you how to fix it, you'll need to show me the whole line you are trying to put in cron.
 

SweetAndLow

Sweet'NASty
Joined
Nov 6, 2013
Messages
6,421
Hi,

Yes, still same error - here is email's subject from one PC:
Code:
Cron <root@DesktopNAS> PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin" /usr/bin/lockf -s -t 0 -k "/mnt/xxx/Backup/Klienci5" /usr/local/bin/rsync -r -t -z --exclude node_modules --log-file="/mnt/xxx/xxx/BackupLogs/backup_5/`date +
Why is the command cut short? There is no closing back tick.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
My advice is to package your rsync task as a shell script. A script is much easier to debug and get working smoothly. Then all you have to do is specify the script in your chron task, instead of an immensely long, complicated command. Like this:
chron-tasks.jpg
 
Top