creating a cronjob in Ubuntu CLI

Get help for specific problems
Posts: 4
Joined: 10 Nov 2022

eqpaisley

Trying to sort out how to have a file sync profile I've set up run once a day at a specific time. I know how to use crontab, but when I test my command from the terminal I get a series of errors:
FreeFileSync /home/MYUSER/Documents/DropboxtoLocal.ffs_batch
Cannot write file "/home/remote-media/Movies/sync.ffs_lock". ESPIPE: Illegal seek [write]
Cannot write file "/home/remote-media/Movies/sync.ffs_lock". ESPIPE: Illegal seek [write]
Cannot write file "/home/remote-media/TV/sync.ffs_lock". ESPIPE: Illegal seek [write]
Cannot write file "/home/remote-media/Movies/sync.ffs_lock". ESPIPE: Illegal seek [write]
Cannot write file "/home/remote-media/TV/sync.ffs_lock". ESPIPE: Illegal seek [write]
I was assuming this was a permissions error, but if I sudo it or even switch and run as root, it still throws errors:
Authorization required, but no authorization protocol specified
14:46:09: Error: Unable to initialize GTK+, is DISPLAY set properly?
This is a REMOTE desktop machine with a gui. Ubuntu 22. Thanks in advance for any help
Posts: 345
Joined: 7 Jan 2018

bgstack15

The first error message sounds like a filesystem-level problem, and not really a permission problem. Would you please share the output of:
mount | grep /home/remote-media
The second error: FreeFileSync is a graphical program and needs environment variable DISPLAY set. In your cron job (search this forum for other cron discussions for examples). You will also need that DISPLAY variable set for if you run FreeFileSync with sudo. Alas, I don't have time now to explain that at the moment.
Posts: 4
Joined: 10 Nov 2022

eqpaisley

Ok, thanks, I'll search the forums.
Posts: 4
Joined: 10 Nov 2022

eqpaisley

I gotta say, it's weird there's no sticky or guide. Setting up a cron on Ubuntu can't be so rare a use case, and this is a really weird and special set of things you have to do to make a linux program work via cron. I've found 10 different contradictory posts and no solid answer.
Posts: 345
Joined: 7 Jan 2018

bgstack15

Cron is for automated tasks, and graphical programs make for poor automated tasks. I understand the appeal of FreeFileSync being automated because it's the same as the graphical one. It's literally the same thing, so it needs a graphical environment ($DISPLAY) and all of the weight that comes with that.

I'm pretty sure I've answered the cron question multiple times on this forum, and they should at least resemble each other if not look identical. Hopefully you can adapt one of them for your situation too.
Posts: 4
Joined: 10 Nov 2022

eqpaisley

Appreciate your reply. I'll keep plugging away at it
User avatar
Site Admin
Posts: 7505
Joined: 9 Dec 2007

Zenju