3

I need to run a Qt application on startup with root permission , below is the script I created using systemctl named QtApp.service

[Unit]
Description=QtApp

[Service]
ExecStart= exec su -l user -c 'export DISPLAY=:0; /QtInst/QtApp'
Restart=always

[Install]
WantedBy=multi-user.target

But when I run the command to start the service sudo systemctl start QtApp.service I am getting following error

Failed to start QtApp.service: Unit QtApp.service is not loaded properly: Invalid argument.

Here is the details of error

systemctl status QtApp.service
● QtApp.service - QtApp
   Loaded: error (Reason: Invalid argument)
   Active: inactive (dead)

Jul 06 15:23:54 user-pc systemd[1]: [/etc/systemd/system/QtApp.service:5] Executable path is not absolute, ignoring: exec su -l user -c 'export DISPLAY=:0; /QtInst/QtApp'
Jul 06 15:23:54 user-pc systemd[1]: QtApp.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Jul 06 15:26:08 user-pc systemd[1]: [/etc/systemd/system/QtApp.service:5] Executable path is not absolute, ignoring: exec su -l user -c 'export DISPLAY=:0; /QtInst/QtApp'
Jul 06 15:26:08 user-pc systemd[1]: QtApp.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.

3 Answers 3

3

Executable path is not absolute -- it means exec.

Generally exec makes no sense here. It's a shell builtin that replaces the shell with a given command. There is no absolute path to exec executable because there is no executable.

su is an executable. The line may be

ExecStart=/bin/su -l user -c 'export DISPLAY=:0; /QtInst/QtApp'

But using su may not be a good idea in systemd service. See: How do I make my systemd service run via specific user and start on boot?

1

Generally, the "Invalid argument" here is the unit definition file itself. To debug it you can use:

sudo systemd-analyze verify QtApp.service

or in case of user's local service:

sudo systemd-analyze --user verify QtApp.service
0

The error says

Executable path is not absolute, ignoring: exec su -l user -c 'export DISPLAY=:0; /QtInst/QtApp'

Try to use the absolut path (e.g. /usr/local/QtInst/QtApp) instead of /QtInst/QtApp.

This might be relevant.

3
  • Actually the executable is in the folder in /QtInst/
    – CodeDezk
    Jul 6, 2018 at 11:32
  • Have you tried to delete the space after ExecStart= ? and set it in quotes, ExecStart="exec su -l user -c 'export DISPLAY=:0; /QtInst/QtApp'" Jul 6, 2018 at 11:39
  • No, I will try it
    – CodeDezk
    Jul 6, 2018 at 11:45

You must log in to answer this question.

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