Hello all,
I am using FFS for years on my Ubuntu server. I am trying for nearly the same time to get a sudo cronjob for a batch sync to work without success.
I tried nearly everything I found in the web but all is stopping with this error message:
Error: Unable to initialize GTK+, is DISPLAY set properly?
Is there a working instruction?
here the latest entry in crontab which is sometimes working for non sudo but never for sudo
in sudoers FreeFileSync is allowed to be run without password
You share information about su and sudo but I don't see that invoked in your command at all. Is this in the user crontab (crontab -e)?
If this is in a file in /etc/cron.d/ then you will probably want to add the user after the time specification:
If are having trouble with DISPLAY=:10.0, then perhaps you need to adjust which DISPLAY you use. I don't know the defaults for Ubuntu. Perhaps :0 or :0.0 is the default "console" value. Chances are you see the DISPLAY=:10.0 when you use vnc or some other remote-desktop type connection to your server.
If you want to get crazy with it, you could probably install Xvfb which creates a dummy X server (X11 Virtual Frame Buffer). See this post.
When you ssh to your server, and you have a $DISPLAY value in that session, then ssh is doing X-forwarding. That :10.0 session will not exist when you do not have that ssh session running. You probably don't want to try to use that.
If you want to get really messy, you can learn which pid (process id) is running for lightdm/gdm/kdm/sddm (your display manager; that is, the login screen on the console). Use ps -ef and find one of those, or your chosen display manager. Call that process's pid $PID for the next step.
tr '\0' '\n' /proc/$PID/environ | grep DISPLAY
If your Ubuntu server does not run any X11 session at all, then you would need to run Xvfb as described in that linked post.
I tried the xvfb-run command and it worked from cli. Next try will be adding it to sudo crontab.
I will report tomorrow :)
I am using lightdm and tried the command (after finding PID) but without success on the first try (missing operator). I did not deep dive because xvfb worked