For some reason, my backup is not working, when it is started by cron.

Crontab entry

0 10 * * * /home/yzT/BackupDaily.sh



/home/yzT/Tools/FreeFileSync/FreeFileSync /home/yzT/Tools/FreeFileSync/BackupDaily.ffs_batch

I can see cron starting my backup script in syslog.

Oct 20 10:00:01 debian CRON[2589]: (yzT) CMD (/home/yzT/BackupDaily.sh)

When I run it manually, the backup system (FreeFileSystem) creates a log file on my Desktop and I can see updated files in the backup directory. But via cron I do not get a logfile nor see any updates.

How can I find/fix the problem?


I found the root of the problem. Switched to TTY and run the script, and I get the following message: Error: Unable to initialize GTK+, is DISPLAY set properly?. So, although there is no GUI using the script, it seems the script wants to have access to the GUI application. How can I fix this?

  • What makes you think it hasn't run ? @Freds suggestion to output a line into a logfile would be a useful diagnostic tool. In BackupDaily.sh you could add (echo "Backup daily running"; date)>>/home/yzT/bkup.log
    – X Tian
    Oct 20 '15 at 10:05
  • Compare your interactive env with the cron one. Probably something missing, causing the FreeFileSync to error out
    – Jeff Schaller
    Oct 20 '15 at 10:15
  • @XTian because the BackupDaily.ffs_batch actually saves a log file on Desktop, and it's not there. And however, if I manually run the script, it is. And basically... because there is no changes at the destination.
    – Ay0
    Oct 20 '15 at 12:06

If you are the only user on the system, you can just edit your crontab (with crontab -e) and add DISPLAY=:0.0 at the top of the file.

Alternatively, you can try running your backup job like so:

/home/yzT/Tools/FreeFileSync/FreeFileSync /home/yzT/Tools/FreeFileSync/BackupDaily.ffs_batch --display=:0.0

  • ok, now it works. Just for the record, the --display=:0.0 version doesn't work, but adding DISPLAY=:0.0does work.
    – Ay0
    Oct 20 '15 at 19:40
  • On Debian, I had to and "env DISPLAY=:0.0" at the begging to make it work. As in " * * * * env DISPLAY=:0.0 /home/yzT/Tools/FreeFileSync/FreeFileSync /home/yzT/Tools/FreeFileSync/BackupDaily.ffs_batch"
    – Damon
    Feb 2 '17 at 6:01

Files with extension .ffs_batch are an xml text associated with FreeFileSync app. Therefore, there are two correct ways to program it in cron (crontab -e):

export DISPLAY=:0; /path_to/FreeFileSync /path_to/file.ffs_batch


/path_to/FreeFileSync /path_to/file.ffs_batch --display=:0.0

The error "Unable to initialize GTK +, is DISPLAY set properly?" it is produced by not defining who executes the task, therefore this must be specified:

sudo crontab -e
# or
crontab -e

You must also specify the hour / minute / second / day / week / month when the task will be executed. Example:

0 10 * * * export DISPLAY=:0; /path_to/FreeFileSync /path_to/task.ffs_batch
# or
@weekly export DISPLAY=:0; /path_to/FreeFileSync /path_to/task.ffs_batch

Source: Mirror synchronization


You need to use 1-59 instead of * in your cron job

1 10 * * * /home/yzT/BackupDaily.sh
  • can you edit your post with the place to put 1-59 ? On a side note, I am not sure this answer the question.
    – Archemar
    Oct 20 '15 at 9:55
  • @yzT another way, make a log record for you cron task. 0 10 * * * /home/yzT/BackupDaily.sh >> /tmp/cron.log 2>&1
    – Fred
    Oct 20 '15 at 9:58
  • 1
    0 is perfectly valid for any of these fields.
    – Bram
    Oct 20 '15 at 10:39
  • This answer is wrong on so many levels... "instead of *" and then you replace the 0, not the *. And * and 0 are valid, as Bram pointed out
    – wurtel
    Oct 20 '15 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.