Systemctl - Failed at step Group spawning

10,267

If somebody has similar problem then just remove User and Group from service file. I don't know why, but without them it works pretty well. So the final working service description is:

Description=Service desc

[Service]
Type=oneshot
Environment=DISPLAY=:0.0
Environment=XAUTHORITY=/home/albert/.Xauthority
Environment=HOME=/home/albert/
RemainAfterExit=true
StandardOutput=journal

ExecStart=/home/albert/.startup-script.sh

[Install]
WantedBy=default.target
Share:
10,267
JiangHongTiao
Author by

JiangHongTiao

I was born in ambulance...

Updated on June 15, 2022

Comments

  • JiangHongTiao
    JiangHongTiao almost 2 years

    I have a problem with automatic running of service. I would like to run a script after user login. Once I have succeeded, however when I tried to automatize it, I'm getting an error and I can't find a mistake.

    Service:

    Description=Service desc
    
    [Service]
    Type=oneshot
    Environment=DISPLAY=:0.0
    Environment=XAUTHORITY=/home/albert/.Xauthority
    Environment=HOME=/home/albert/
    User=albert
    Group=albert
    RemainAfterExit=true
    StandardOutput=journal
    
    ExecStart=/home/albert/.startup-script.sh
    
    [Install]
    WantedBy=default.target
    

    location: /home/albert/.config/systemd/user/startup-service.service

    permissions: -rw-r--r-- 1 albert albert 306 Jan 2 14:49 startup-service.service

    Script

    Permissions: -rwxr-x-r-x 1 albert albert 86 Jan 2 13:30 /home/albert/.startup-script.sh

    Log

    Jan 02 17:03:27 irpi-epsilon systemd[734]: Service desc
    -- Subject: Unit UNIT has begun start-up
    -- Defined-By: systemd
    -- Support: https://www.debian.org/support
    -- 
    -- Unit UNIT has begun starting up.
    Jan 02 17:03:27 irpi-epsilon systemd[1025]: startup-script.service: Failed at step GROUP spawning /home/albert/.startup-script.sh: Operation not permitted
    -- Subject: Process /home/albert/.startup-script.sh could not be executed
    -- Defined-By: systemd
    -- Support: https://www.debian.org/support
    -- 
    -- The process /home/albert/.startup-script.sh could not be executed and failed.
    -- 
    -- The error number returned by this process is 1.
    Jan 02 17:03:27 irpi-epsilon systemd[734]: startup-script.service: Main process exited, code=exited, status=216/GROUP
    Jan 02 17:03:27 irpi-epsilon systemd[734]: Service desc
    -- Subject: Unit UNIT has failed
    -- Defined-By: systemd
    -- Support: https://www.debian.org/support
    -- 
    -- Unit UNIT has failed.
    -- 
    -- The result is failed.
    Jan 02 17:03:27 irpi-epsilon systemd[734]: startup-script.service: Unit entered failed state.
    Jan 02 17:03:27 irpi-epsilon systemd[734]: startup-script.service: Failed with result 'exit-code'.
    

    I have called:

    systemctl --user daemon-reload
    systemctl --user enable startup-script.service
    systemctl --user start startup-script
    

    And I'm trying to do it on Raspberry Pi 3. Thanks a lot for pointing me at any direction.

  • Folaht
    Folaht over 6 years
    I can't do that. I need to run my service as a user.
  • JiangHongTiao
    JiangHongTiao about 6 years
    By the '.startup-script.sh' I'm running chrome browser and it's running under the currently logged in user. So the user 'albert' from settings above.
  • Folaht
    Folaht about 6 years
    Disregard my comment. I was able to run it as user as well despite it not explicitly stated, though I don't know how I achieved that.
  • JiangHongTiao
    JiangHongTiao about 6 years
    probably it is enough when it's located in user's directory. It's just my assumption I didn't study it in detail. However it's doing what I need, so it's enough :) Thanks for your concern!
  • chikamichi
    chikamichi about 6 years
    I can confirm when using --user services it binds the process to the user owning the service.