I have recently installed FreeFileSync on a my PC and managed to to getting the RealTimeSync working perfectly fine. All that is left to do is automatically call the script at start up. Initially, I used Cron with the @reboot parameter but that did not work out. So I decided to use systemd instead. I have created a user service file called sync.service which I have enabled and works perfectly fine when manually called via the systemctl --user start sync_1 command. However, it encounters errors on startup. Could anybody please? I am not sure where I am going wrong.
[Unit]
After=network.service
[Service]
Environment="DISPLAY=:0"
ExecStart=/home/user/Desktop/sync.sh
[Install]
WantedBy=default.target
Below is the error I encounter when I check the status of the systemd file after startup.
sync_1.service Loaded: loaded (/etc/xdg/systemd/user/sync_1.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sun 2020-06-14 21:19:19 BST; 47s ago Process: 1859 ExecStart=/home/user/Desktop/sync.sh (code=exited, status=255/EXCEPTION) Main PID: 1859 (code=exited, status=255/EXCEPTION)
Your
.service
file containsDISPLAY:=0
, whitch is a pointer to the X server's screen 0.However, the X server is not started at system startup time, but only after you perform a GUI login.
So, when
/home/user/Desktop/sync.sh
, at system startup time, tries to talk to the X server handlingDISPLAY:=0
, there's NO X server, and things blow up real good.The startup of X server dependent tasks should be done by a
.desktop
file in$HOME/.config/autostart/
. Readman desktop-file-edit desktop-file-validate
. Find examples withlocate .desktop
. Read the "Desktop Entry specifacation" https://freedesktop.org/wiki/Specifications/desktop-entry-spec/