Ubuntu FFS with root cron job

Discuss new features and functions
Posts: 2
Joined: 4 Jan 2021

TimW

There has been a lot of discussion about the feasibility of running FFS as a root cron job on Linux systems with the main issue being that FFS requires X. The following notes explain my solution to this problem in an Ubuntu 20.04 environment.

1) Install and configure xserver-xorg-video-dummy following the instructions at https://techoverflow.net/2019/02/23/how-to-run-x-server-using-xserver-xorg-video-dummy-driver-on-ubuntu/. The config file dummy-1920x1080.conf should be in the same location as your default configuration file e.g. /etc/X11/xrdp/dummy-1920x1080.conf

2) Create a bash script which will be run by cron. I have placed this script in the same location as my FFS installation /opt/FreeFileSync_11.5/Bin
#!/bin/bash -l

echo ""
date

export DISPLAY=:7
echo ""
echo "Starting X:"
echo "Waiting for 2 seconds to allow X to start"
Xorg $DISPLAY -config xrdp/dummy-1920x1080.conf &
sleep 2
echo ""

/opt/FreeFileSync_11.5/FreeFileSync '/opt/FreeFileSync_11.5/Resources/SyncSettings_Server.ffs_batch'

echo "Kill all child processes which shuts down the Xorg instance."
pkill -P $$

echo "Successful completion"
This script uses DISPLAY :7 but could be set to any unused value. The key feature of this script is that it starts and stops an instance of Xorg.

3) Edit the root crontab with
sudo crontab -e
and add something like
# FreeFileSync archiving
26 12 * * * /opt/FreeFileSync_11.5/Bin/ffs_batch.sh >> /var/log/FreeFileSync/ffs_batch.log 2>&1
I hope that this solution provides a workable template for others to employ.
Posts: 305
Joined: 7 Jan 2018

bgstack15

Would xvfb-run be a viable option? I haven't ever tried it myself, but using xvfb could be a lot simpler than most of that.
I think you could try
xvfb-run /opt/FreeFileSync_11.5/FreeFileSync /opt/FreeFileSync_11.5/Resources/SyncSettings_Server.ffs_batch
As the sole contents of your script.
Posts: 2
Joined: 4 Jan 2021

TimW

I did think about going down the xvfb route but there were reports of stability issues and the need to install the xvfb server. The additional level of complexity in the solution I am using comes from the creation of the dummy configuration file which was just a copy and paste exercise. As I didn't try xvfb it would be interesting to know if other people found it easy and reliable to use.
When using xvfb-run do you not also need to use the "-d" or "-a" option to assign a display?
Posts: 8
Joined: 2 Mar 2021

Mac-Gyver

Hi,

Looking for post with cron, because i would like to run FFS automatically, i find this one.

And first, this question : why using root, and not user context ?

In my case, i'm the only user of my PC, and a launch under /var/spool/cron/crontabs/"user" is enough for me.

Anyway, i've the same problem with user or root crontab.

The sync doesn't work, and i don't know why.

I'm sure cron works well, because a simple command like cp is launched.

but the command : "/opt/FreeFileSync /path-to-config_file/config_file.ffs_batch" doesn't works, while it works when launched from terminal window.

Does someone know how to do this ?

Ubuntu 18.04 and FFS 11.8