Issue Scheduling FreeFile Sync on Pop!_OS

Get help for specific problems
Posts: 18
Joined: 9 Dec 2021

parkernathan

I'm trying to schedule FreeFileSync Flatpak edition 11.17 on a System76 notebook running Pop!_OS 20.04 LTS. I'm using Zeit to edit my crontab.

Crontab command is:
DISPLAY=0 "/usr/bin/flatpak run org.freefilesync.FreeFileSync" "/home/parkernathan/Documents/WebMate-Documents.ffs_batch" 1>>~/ffs.log 2>&1
Scheduled at 6PM Local Time.

ffs.log output is showing:
/bin/sh: 1: /usr/bin/flatpak run org.freefilesync.FreeFileSync: not found
Running:

"/usr/bin/flatpak run org.freefilesync.FreeFileSync"

Does launch the FreeFileSync GUI.

System76 Support is having me post here to see what I need to tweak the command to in order for this to run correctly.

Thanks!
Posts: 306
Joined: 7 Jan 2018

bgstack15

You need to remove the quote marks from the second token from the crontab entry. The way the command is interpreted by cron, is that it is looking for a file that is named "/usr/bin/flatpak run org.freefilesync.FreeFileSync" (excluding the quotes). That is, a file with those spaces in the name. If it found that file, it would then try to execute it. That would be quite an unusual filename! The difficulty lies in the interpretation of the contents of the file. Double (and even single) quote marks cause everything inside to be interpreted a particular way, but certainly everything a pair of quote marks will be seen as one item. And that first non-variable (non-equal-sign token) is the binary that cron wants to execute.

If your cron entry looked like:
DISPLAY=0 /usr/bin/flatpak run org.freefilesync.FreeFileSync "/home/parkernathan/Documents/WebMate-Documents.ffs_batch" 1>>~/ffs.log 2>&1
Then cron would find the /usr/bin/flatpak, and then pass these parameters to it. The double quotes around your path to the .ffs_batch file are fine, because that is indeed one file. And if you had a space in the directory names or filename, the quotes would protect the space and prevent the space from making the two parts into two separate tokens.

Welcome to the world of Linux shell parsing of spaces!

I always fail with the details of the DISPLAY variable. If it works for you to set =0 then that's great! I would have expected that DISPLAY=:0 would work. X11 displays tend to use the syntax ":0" for the first (or zero-indexed first) display server. Sometimes ":0.0" if there's network stuff going on iirc.
Posts: 18
Joined: 9 Dec 2021

parkernathan

Got it. Thanks for clarifying! I've removed the quotes. I'll test it tomorrow and see how it goes and reports back.

Once it's working, I'll need to replace outputting to the log to instead output to dev null since I won't want the log file. What do I need to change in the command to output to dev null once I know it's working?

Thanks!
Posts: 306
Joined: 7 Jan 2018

bgstack15

That is a great question. It is rather typical for cron entries to just redirect everything to /dev/null.

You would just change the 1>>~/ffs.log 2>&1 bit to 1>/dev/null 2>&1.
Posts: 18
Joined: 9 Dec 2021

parkernathan

New Error:

18:00:01: Error: Unable to initialize GTK+, is DISPLAY set properly?

How do I resolve this?

Thanks!
Posts: 306
Joined: 7 Jan 2018

bgstack15

If your DISPLAY=:0 displays this error message, then that display either is owned by a different user or it does not exist.
You can check what the current display, on a regular logged in session on the console, by opening a terminal and running:
tr '\0' '\n' < /proc/$$/environ | grep DISPLAY
I was surprised that mine is:
DISPLAY=:0.0
I haven't read the docs on why the .0 appears, but anyway, yours might look like that.

The login screen (in Linux parlance that would be called the "display manager") usually runs on DISPLAY=:0 or DISPLAY=:0.0 variable.
Do you expect that your computer is sitting at the login screen, when you want this cron entry to run? Or will you be logged in at the time?
Posts: 18
Joined: 9 Dec 2021

parkernathan

Thanks for the followup!

When I'm running FreeFileSync, I'll have the machine powered on and logged into my user account. My screen may occasionally turn off requiring me to wake the screen and sign in if I'm away from the machine (to save on energy and ensure someone doesn't come up and use my machine when I'm away).

The output to the grep DISPLAY command is:
DISPLAY=:1
Do I need to change my Display to DISPLAY=:1?

Thanks!
Posts: 306
Joined: 7 Jan 2018

bgstack15

Yes, go ahead and try that value.
Posts: 18
Joined: 9 Dec 2021

parkernathan

Great. I just changed it and will see what happens tomorrow.
Posts: 18
Joined: 9 Dec 2021

parkernathan

This showed up in my error log today. Do I need to do anything with this?
Gtk-Message: 18:00:01.166: Failed to load module "canberra-gtk-module"
Posts: 306
Joined: 7 Jan 2018

bgstack15

That message is not important. GTK always throws tons of warnings. In this case, canberra is a library related to playing sounds, but I'm pretty sure FreeFileSync doesn't use that one to play the notification sounds.

If you got that far, then it sounds like the app ran!
User avatar
Site Admin
Posts: 7058
Joined: 9 Dec 2007

Zenju

If your DISPLAY=:0 displays this error message, then that display either is owned by a different user or it does not exist. bgstack15, 05 Mar 2022, 04:16
Maybe FFS can/should help out here? The DISPLAY environment variable is required by GTK+ init (which alternatively offers to override this variable via command line e.g. with "--display=:0").

It seems in 90% of cases display ID is 0. FFS could set "DISPLAY=:0" automatically during start in case the environment variable is not set (apparently when using cron). Worst that can happen is that GTK+ init still fails with "Unable to initialize GTK+, is DISPLAY set properly?".

Thougths?
User avatar
Site Admin
Posts: 7058
Joined: 9 Dec 2007

Zenju

I'm pretty sure FreeFileSync doesn't use that one to play the notification sounds. bgstack15, 07 Mar 2022, 15:27
That's right. It seems not even wxWidgets is using canberra. Apparently this module is internally used by GTK, which also emits the warning during init. I have no idea what sounds canberra is producing. FFS could hide this message if canberra is 100% superfluous in the FFS context.

Thougths?
Posts: 18
Joined: 9 Dec 2021

parkernathan

Great! I can confirm the sync worked as FFS is showing the correct time as the last sync.

Thanks again for all your assistance!
Posts: 306
Joined: 7 Jan 2018

bgstack15

I wouldn't bother doing anything with the canberra warning. GTK applications throw all kinds of warnings because GTK has so many hooks into things. It's not in scope for an application like FreeFileSync to deal with any superfluous warnings from GTK.

Additionally, please do not try to manipulate DISPLAY internally in FreeFileSync. That sounds like behavior I've never ever heard of. If the user does not provide a DISPLAY, it should fail exactly the way it currently does. There are unusual times when one might have multiple X servers running (such as remote desktop connections) and if FreeFileSync goes around picking one for itself, it might get it wrong.
Posts: 18
Joined: 9 Dec 2021

parkernathan

Good info! Mine's working smoothly now, so I have no plans to touch it further. :-)