Start FreeFileSync with cron

Get help for specific problems
Posts: 2
Joined: 23 May 2024

flipflip

Hello everyone,

I am trying to set up the automatic launch of backups on my PC using cron on Fedora 39 with FreeFileSync installed via Flathub.
#crontab -e

DISPLAY=:0
35 07 * * * /usr/bin/flatpak run org.freefilesync.FreeFileSync /home/xxx/Documents/backup-xxx.ffs_batch
In the logs of my PC at the scheduled time for my cron task, I have the following message
mai 23 07:35:01 aaa CROND[6491]: (xxx) CMDOUT (Authorization required, but no authorization protocol specified)
mai 23 07:35:01 aaa CROND[6491]: (xxx) CMDOUT ()
mai 23 07:35:01 aaa CROND[6491]: (xxx) CMDOUT (07:35:01: Error: Unable to initialize GTK+, is DISPLAY set properly?)
mai 23 07:35:01 aaa CROND[6491]: (xxx) CMDEND (/usr/bin/flatpak run org.freefilesync.FreeFileSync /home/xxx/Documents/backup-xxx.ffs_batch)
In the documentation, it is recommended to use gnome-scheduler, but apparently it is no longer maintained and the RPM package is not available for Fedora.

Do you have any suggestions?
Thanks in advance.
Posts: 2
Joined: 23 May 2024

flipflip

Solution
57 08 * * * env DISPLAY=:0 XAUTHORITY=`find /run/user/1000/.mutter*` /usr/bin/flatpak run org.freefilesync.FreeFileSync "/home/xxxx/Documents/backup-xxxx.ffs_batch"
Posts: 1092
Joined: 8 May 2006

therube

So it was this "XAUTHORITY" bit.
Something to the effect that you're (setting a variable ?) telling things to run with .mutter's permissions, is that the idea (or at least in a very very broad sense) ?
User avatar
Site Admin
Posts: 7332
Joined: 9 Dec 2007

Zenju

Posts: 1
Joined: 2 Jan 2025

Alarion

I Followed the instructions provided in the manual on Debain 12 but it did not work kept getting the error Error: Unable to initialize GTK+, is DISPLAY set properly?.

The following command worked in my case 15 22 * * * cd /home/user/Documents && DISPLAY=:1 FreeFileSync "SyncFiles.ffs_batch'
Posts: 2
Joined: 19 Jan 2025

lynk81

So I tried to follow all the help and guidance here and for some reason on my system I just could not get it to work. The command just wouldn't run from CRON which I am not pretty sure has to do with DISPLAY and XAUTHORITY

I ran echo $DISPLAY and echo $XAUTHORITY and put them in a script like the below, which works perfectly.

#!/bin/bash
# run_freefilesync

# Log file path for debugging
LOGFILE="/path/path/path/ffs.log"

# Set the DISPLAY variable to your current GNOME display (commonly :0)
export DISPLAY=:0

# Optionally set XAUTHORITY if needed (adjust the path to match your user)
export XAUTHORITY=/run/user/1000/.mutter-Xwaylandauth.JN6Y02

# Run FreeFileSync with the batch file
# Redirect both stdout and stderr to /dev/null to suppress any output
/opt/FreeFileSync/FreeFileSync "/path/path/path//SyncSettings.ffs_batch" > /dev/null 2>&1

# Record the finish time
echo "Script ended at $(date)" >> "$LOGFILE"
User avatar
Site Admin
Posts: 7332
Joined: 9 Dec 2007

Zenju

# Set the DISPLAY variable to your current GNOME display (commonly :0)
export DISPLAY=:0 lynk81, 01 Feb 2025, 05:46
This is superfluous. (because it is the default)
# Optionally set XAUTHORITY if needed (adjust the path to match your user)
export XAUTHORITY=/run/user/1000/.mutter-Xwaylandauth.JN6Y02 lynk81, 01 Feb 2025, 05:46
This is probably what does the trick for you.
# Redirect both stdout and stderr to /dev/null to suppress any output lynk81, 01 Feb 2025, 05:46
I would not recommend this. FreeFileSync should be silent, if not you'll want to see the errors.
Posts: 2
Joined: 19 Jan 2025

lynk81

Thanks Zenju, I have to admit that was ChatGPT working off my prompt… I’ll test making the changes you mention above and report back.