Tip - alternative for gnome-schedule on Linux

Get help for specific problems
tmountney
Posts: 6
Joined: 23 May 2019

Post by tmountney • 02 Jun 2019, 16:39

gnome-schedule (GS) is not available as a package with Debian - not sure if this is true for all Debian based distros. GS was removed from Debian December 2015 with version 2.1.1-4.

I have a workaround to eliminate the use of gnome-schedule (GS) and the "X application" option to create a task schedule.

It requires using a script rather than directly scheduling the FFS batch. I've been testing this for 7+ days at this time and it appears to work with NO side effects - the batch runs, files are sync'd, logs are generated as expected.

The first script ffs_sync.sh code snippet:

Code: Select all

        ... statements
# run the back-up
	export DISPLAY=:0
	/path/to/FreeFileSync/FreeFileSync  '/path/to/FreeFileSync/cf.ffs_batch'
        ... statements
The key is the
export DISPLAY=:0
statement.

I tried using gnome-terminal :

Code: Select all

        ... statements
# run the back-up
	export DISPLAY=:0
	gnome-terminal -x /path/to/FreeFileSync/FreeFileSync '/path/to/FreeFileSync/cf.ffs_batch'
        ...statements
It worked but a terminal flashed-up while the FFS batch was running - very distracting and annoying.

The crontab job is simple - run ffs_sync.sh (use first code snippet example) everyday at 3:15 AM:

Code: Select all

15 3 * * * /path/to/FreeFileSync/ffs_sync.sh
Adding script logging works as well:

Code: Select all

15 3 * * * /path/to/FreeFileSync/ffs_sync.sh >> /path/to/mylogs/ff_sync.log 2>&1 
GS can still be used when available - select "Default behaviour" rather than "X application"

This works on Devuan and Linux Mint 19 32/64 bit systems.

User avatar
Zenju
Site Admin
Posts: 5042
Joined: 9 Dec 2007

Post by Zenju • 04 Jun 2019, 14:04

Ideally, FFS would somehow offer a portable task scheduler (ramp up RTS?), but let's not hold our breath: Until then it probably makes sense to replace the gnome-schedule manual section by a short intro to "crontab" in the context of FFS showing the minimum steps needed, such as:

Code: Select all

EDITOR=gedit crontab -e
It seems we can get rid of the sh file:

Code: Select all

*/1 * * * * DISPLAY=:0 /path/to/FreeFileSync/FreeFileSync ${HOME}/Desktop/SyncJob.ffs_batch
or alternatively:

Code: Select all

*/1 * * * * export DISPLAY=:0; /path/to/FreeFileSync/FreeFileSync ${HOME}/Desktop/SyncJob.ffs_batch

tmountney
Posts: 6
Joined: 23 May 2019

Post by tmountney • 07 Jun 2019, 20:35

Over several days, I tested both:

Code: Select all

*/1 * * * * DISPLAY=:0 /path/to/FreeFileSync/FreeFileSync ${HOME}/Desktop/SyncJob.ffs_batch

Code: Select all

*/1 * * * * export DISPLAY=:0; /path/to/FreeFileSync/FreeFileSync ${HOME}/Desktop/SyncJob.ffs_batch
Neither executes the scheduled FFS batch - no log is generated, no files are sync'd.

The same FFS batch configuration, when run from the application, works as expected - a log is generated, files are sync'd

Using the same FFS batch configuration and executing it from a scheduled script that exports DISPLAY and then executes the FFS batch, executes as expected - a log is generated, files are sync'd.

It "seems" that using a scheduled script that exports DISPLAY and then executes the FFS batch is required.

I tested this on 3 distros - Linux Mint 19 32/64 bit and Devuan 2 64 bit - with the same results; it only works if I use a script...

User avatar
Zenju
Site Admin
Posts: 5042
Joined: 9 Dec 2007

Post by Zenju • 12 Jun 2019, 12:19

I don't see why the crontab syntax should require a sh file on one system but not on the other. I'd suggest checking what error information is available from crontab. E.g. it may have sent an email to the local account in /var/spool/mail/<username>

bgstack15
Posts: 79
Joined: 7 Jan 2018

Post by bgstack15 • 15 Jun 2019, 22:20

If your provided examples use the shell variable "${HOME}" specifically, the cron jobs will not be able to send the right variable. The variable $HOME is a bash built-in, which from man bash(1) is described:
HOME

The home directory of the current user; the default argument for the cd builtin command. The value of this variable is also used when performing tilde expansion.
Cron generally runs as root, and you can simply tell a cron job to run as a particular user. However, exact ways of doing that will vary, and your cron table doesn't look like the one I'm familiar with where you make the first value after the timing be equal to the username who will run the command.

And instead of explaining the nuances of cron here, I will tell you: You should change the environment-dependent variable $HOME to be a specific path name.

So:

Code: Select all

*/1 * * * * DISPLAY=:0 /path/to/FreeFileSync/FreeFileSync /home/tmountney/Desktop/SyncJob.ffs_batch

tmountney
Posts: 6
Joined: 23 May 2019

Post by tmountney • 24 Jun 2019, 01:21

Retested to confirm direct batch scheduling options...

Started fresh:
  • Deleted all FFS related crontab jobs
  • Using FFS, deleted the GUI and batch configs: Main.ffs_gui, Main.ffs_batch
  • Rebooted system
  • Configured/saved new GUI and batch configs: Main.ffs_gui, Main.ffs_batch
  • Using FFS app, tested/confirmed both GUI and batch configs executed as expected - no errors, source/destination sync'd, logs created

Schedule Test 1
Created new USER crontab job:

Code: Select all

*/1 * * * * DISPLAY=:0 /path/to/FreeFileSync/FreeFileSync /path/to/Main.ffs_batch
  • Added new-file-1 to source
  • Confirmed that cron job executed - no errors, source/destination sync'd
  • Checked syslog - no CRON errors for FFS
  • Checked FFS batch status in log-file - no errors, new-file-1 sync'd to destination
Schedule Test 2
Created new USER crontab job:

Code: Select all

 */1 * * * * export DISPLAY=:0; /path/to/FreeFileSync/FreeFileSync /path/to/Main.ffs_batch
 
  • Added new-file-2 to source
  • Confirmed that cron job executed - no errors, source/destination sync'd
  • Checked syslog - no errors
  • Checked FFS batch status in log-file - no errors, new-file-2 sync'd to destination
I tested this scenario on 3 systems/distros - Mint 19 32 bit and 64 bit, and Devuan 2 64 bit.

ALL executed successfully - no errors, source/destination sync'd, logs generated on the 3 systems.

Additionally tested both scenarios using ${HOME} as path, on all 3 systems , e.g.:

Code: Select all

*/1 * * * * DISPLAY=:0 ${HOME}/FreeFileSync/FreeFileSync ${HOME}/Main.ffs_batch

*/1 * * * * export DISPLAY=:0; ${HOME}/FreeFileSync/FreeFileSync ${HOME}/Main.ffs_batch
ALL executed successfully - no errors, source/destination sync'd, logs generated on the 3 systems.

I don't know why it didn't work the first time I tested - I followed
the same steps listed above. I allowed the cron job to run for several days - there was not one successful sync.

I probably mis-defined a property, path, or didn't punctuate (use of ';'), correctly... DOH...

My apology to all for any confusion this may have caused...

SO... this confirms that whether scheduling the FFS batch directly, or thru a
script, both execute successfully.