User Tools

Site Tools


wiki:systemd_user_service

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
wiki:systemd_user_service [2021/08/19 11:35] – Add info box antisawiki:systemd_user_service [2023/04/20 21:40] – [systemd --user does not work: 'Failed to connect to bus'] add reboot info antisa
Line 5: Line 5:
  
 Example: Example:
-<code>+<code systemd>
 [Unit] [Unit]
 Description=my npm app Description=my npm app
Line 13: Line 13:
 ExecStart=/usr/bin/npm start ExecStart=/usr/bin/npm start
 WorkingDirectory=/home/debian/mynpmapp/ WorkingDirectory=/home/debian/mynpmapp/
 +Restart=on-failure
  
 [Install] [Install]
Line 18: Line 19:
 </code> </code>
  
-2. From root enable lingering so that it persists over reboots and logouts+2. Enable service 
 +  systemctl --user enable mynpmapp.service 
 + 
 +3. From root enable lingering so that it persists over reboots and logouts
  
   loginctl enable-linger username   loginctl enable-linger username
  
-3. Use ''systemctl --user start|stop <servicename>'' to run service+4. Use ''systemctl --user start|stop <servicename>'' to run service
  
 ===== TROUBLESHOOTING ===== ===== TROUBLESHOOTING =====
Line 38: Line 42:
   export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus"   export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus"
  
-then logout and login again.+then logout and login again. If its still not working and you get na error 
 + 
 +  Failed to connect to bus: No such file or directory 
 + 
 +try rebooting the server.
  
  
Line 50: Line 58:
   * https://serverfault.com/questions/841099/systemd-grant-an-unprivileged-user-permission-to-alter-one-specific-service   * https://serverfault.com/questions/841099/systemd-grant-an-unprivileged-user-permission-to-alter-one-specific-service
   * https://serverfault.com/a/1047069/353235   * https://serverfault.com/a/1047069/353235
 +  * https://unix.stackexchange.com/questions/434494/how-do-i-setup-user-autostart-and-properly-configure-systemd-user-services/434647#434647
  
wiki/systemd_user_service.txt · Last modified: 2023/04/20 22:15 by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki