0

I was trying to execute the below on my linux terminal and it was working fine by creating the backup of the source file at a given location + a log file was getting created with timestamp to the name of the log file.

rsync -av --delete /home/root/Desktop/Test/ /home/root/auto_backups/My_Programs/ /home/root/auto_backups/My_Programs/zz_crontab_logs/`date +\%F_%H-%M-%S-%N`-test1.log

But when I am running the same as a crontab as given below the I am not getting any output at all. Neither the backup of the source file nor the log file.

30 11,22 * * * rsync -av --delete /home/root/Desktop/Test/ /home/root/auto_backups/My_Programs/ /home/root/auto_backups/My_Programs/zz_crontab_logs/`date +\%F_%H-%M-%S-%N`-test1.log

and if i am just trying below command in cron with out the creating the log file it working fine.

30 11,22 * * * rsync -av --delete /home/root/Desktop/Test/ /home/root/auto_backups/My_Programs/

Can some one help on this please.

  • Hi HBruijn, I don't think this is a duplicate question as the other question that you marked here seems its no way related to Rsync. I have also added some more inputs to the question and the description. Please check the same. – AlphaBet Nov 29 '17 at 09:29
  • 1
    Is your question supposed to be about cron or rsync? If your question is about rsync then reproduce the problem without involving cron and update your question, then it can be reopened. If your question is about cron then it surely looks like a duplicate. – kasperd Nov 29 '17 at 14:49
  • Hi, my question is about why rsync not working properly when trying to with cron?, but rest of the cron jobs are working fine. Hence wanted help to fix it. I have also updated the question body with the same details. – AlphaBet Nov 30 '17 at 04:33

1 Answers1

3

As noted in this answer, percent signs need to be escaped.

If that doesn't work, you'll need to review the output/error from the attempt to run the job. You may need to determine why the error output from cron isn't being emailed to you.

Royce Williams
  • 1,364
  • 8
  • 16
  • Hi Royce, when I tried cron with the below(first part to create the back up of the source file) is working ------------ 30 11,22 * * * rsync -av --delete /home/root/Desktop/Test/ /home/root/auto_backups/My_Programs/ ----------------- The problem is only when I am tring to include -------------- /home/root/auto_backups/My_Programs/zz_crontab_logs/date +\%F_%H-%M-%S-%N-test1.log ------------- to the first part. – AlphaBet Nov 29 '17 at 06:20
  • Ah, I misunderstood. Answer updated. – Royce Williams Nov 29 '17 at 06:25