Running CRON Jobs That Require GUI

I am using FreeFileSync utility for mirroring contents of several HDDs, call it software RAID if you must :) This software can be run in batch mode however unlike many Linux native utilities this one is not text mode by default and require more than just a terminal to run.
By any means this fact is not exceptional if you run FreeFileSync manually from some window manager, however things might not work as smoothly if you wish to run FreeFileSync at regular intervals with the help of cron for instance. That was exactly my case that I intend to describe here.

First of all I created a single script that should be called regularly by cron, the script contains all the FreeFileSync calls I need in one place. To test how the script works I added it to crontab and made it scheduled to be executed every minute:
crontab -e
Now just to be on the safe side I restarted cron daemon:

Looking good, now inspecting the logs in /var/log/syslog:


However I did not see any activity on FreeFileSync part and my disks were left unsynchronised.. What gives? What is important to know here is that cron sends you an e-mail in case it has some error to report but in order to get this mail you have to install mail server and some mail client. I went with one of the most popular choices: postfix for server with local-only configuration and mailutils package for text-based client which is called by executing mail command. Both postfix and mailutils should be available in your distro of choice, in case of Debian based flavours sudo apt-get install to the rescue!

Here is what I saw in the e-mail sent to me by cron:

It turns out the issue could be resolved with a simple trick – initialising DISPLAY variable inside the crontab itself. Here we need to remember that cron runs jobs with very limited environment and it is very common that jobs fail because of some environment variable is missing. Below I am setting the proper DISPLAY and make sure my command runs once a day instead of once per minute:

That was all I needed to successfully schedule my cron job. The takeaway is this: mind the environment working with cron, make sure to inspect syslog log and also have the local mail server properly setup in order to get mail from cron in case of issues running the jobs. By the way your inbox should be located in /var/spool/mail/ and the format of the file is human readable so maybe you won’t need mailutils, just postfix.

Backup Your Files

After the important files are in order and synced between devices we sort of get them backed up this way to a certain extent of course – this backup will not make your workstation boot into OS again in case something bad happens with HDD or boot partition.. Below is the list of software I use for full partition/HDD backup.


Acronis True Image: it’s commercial, used it for years, restored backups successfully several times, allows creating live-cd to boot and restore HDD.


clonezilla + partclone: use for full disk backup, free as in beer & speech but make sure you have the compatible pair because clonezilla depends on partclone and in my case (Mint 17 disrto) default partclone was incompatible with default clonezilla version (issue was -z param of partclone). Seems the easiest way to get both correct versions of clonezilla and partclone is to use “Clonezilla Live” distribution on USB stick, installed using tuxboot.

You need a live-cd to boot & backup because partition/HDD you plan to backup has to be unmounted. I was actually looking into using Acronis for Linux but did not feel very enthusiastic about the price of this edition – it seems only Enterprise edition works on Linux with price tag around 1000$..

Deja Dup: home directory incremental backup/restore.


Time Machine? Not sure yet because did not set up backup on my Mac. Will be trying out that option but I’ve read it is now incompatible with Samba shares, however a workaround is available – will test that and update the post.

UPDATE (10.09.2015)
After almost a year I am finally ready to update this post with my OSX preference and this is SuperDuper!, whole disk backup.