1

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)

7
  • 1
    Please provide output of journalctl -xe command.
    – KK Patel
    Commented Jun 16, 2020 at 16:18
  • It's executing before you login and start the X server that DISPLAY=:0 refers to.
    – waltinator
    Commented Jun 16, 2020 at 23:15
  • @waltinator thanks for the response, how might I go about doing that exactly? Commented Jun 17, 2020 at 20:09
  • @KKPatel thank you for the response, any way I can attach the log here as a file? Commented Jun 17, 2020 at 20:10
  • You can edit question and put logs or you can use pastebin.ubuntu.com and provide link in question.
    – KK Patel
    Commented Jun 17, 2020 at 20:12

1 Answer 1

1

Your .service file contains DISPLAY:=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 handling DISPLAY:=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/. Read man desktop-file-edit desktop-file-validate. Find examples with locate .desktop. Read the "Desktop Entry specifacation" https://freedesktop.org/wiki/Specifications/desktop-entry-spec/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .