2

I need to set up an automatic sync between a folder on my Disk and my google Drive, that runs every day, using FreeFileSync.

I created a batch job from FreeFileSync, named syncDrive.ffs_batch, and saved in my FreeFileSync installation folder /home/$USER/bin/FreeFileSync.

the job doesn't work for some reason. I've set up the crontab file as follows:

DISPLAY=:10.0
0 18 * * * /home/$USER/bin/FreeFileSync/syncDrive.ffs_batch

if I manually run the script from terminal, i get a permission error. If i run it with sudo, it says command not found.

Anyone knows how to fix? thanks in advance. Using Ubuntu 19.10

steeldriver
  • 136,215
  • 21
  • 243
  • 336
  • 1
    What command does it say is "not found"? the syncDrive.ffs_batch script, or a command within that script? Did you make syncDrive.ffs_batch executable? – steeldriver Feb 03 '20 at 17:22
  • FWIW I don't think that $USER is set by default in the crontab environment - however $LOGNAME should be (as well as $HOME - which you could use in place of /home/$USER) – steeldriver Feb 03 '20 at 19:01
  • I'm using FreeFileSync under Windows, I like it much. But I feel obliged to tell you the command rsync is much better choice for scripting under Linux. Here is one crazy cool advanced example: https://askubuntu.com/a/1029653/566421 – pa4080 Feb 03 '20 at 19:53

1 Answers1

3

You have to change the command in your crontab to something like:

0 18 * * *   DISPLAY=:0 /home/your-username/bin/FreeFileSync /home/your-username/bin/FreeFileSync/Sync.ffs_batch

to provide full path to the FreeFileSync executable (/home/your-username/bin/FreeFileSync) and to its job-file (/home/your-username/bin/FreeFileSync/Sync.ffs_batch).

N0rbert
  • 99,918
  • Thank you, I'll try in that way. Anyway, do you have any clue on why the simple command doesn't work alone? – Marco Provitina Feb 04 '20 at 05:24
  • The ffs_batch files are XML, so they are not executables. So it will not work this way. You need to call an application to open the file (in this case FreeFileSync to open ffs_batch). – N0rbert Feb 04 '20 at 06:02
  • This got rid of an error I was receiving when running via cron: "Error: Unable to initialize GTK+, is DISPLAY set properly?" – kindaran Aug 25 '20 at 00:25
  • @kindaran you have to debug this by yourself. There may be some changes in FFS. At first try switching to Xorg. – N0rbert Aug 25 '20 at 06:37
  • @N0rbert I'm saying that your suggestion resolved the error I was receiving and now FFS runs just fine via cron. Not sure what you are commenting on. – kindaran Aug 26 '20 at 13:24
  • Was a bit tired, thank you for your feedback, @kindaran :) – N0rbert Aug 26 '20 at 13:51