SHARE
TWEET

Untitled

silver2row Sep 11th, 2019 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;;; systemd user service example
  2. ; See also https://pastebin.com/KXVdTNrL for a system service example.
  3. ;
  4. ; Make sure the directory exists (you only need to do this once):
  5. ;   mkdir -p ~/.config/systemd/user
  6. ;
  7. ; Save this file as:  ~/.config/systemd/user/my-service.service
  8. ;
  9. ; You can use any name instead of "my-service" of course (but then also adjust that
  10. ; in the commands below), as long as it doesn't conflict with any existing user
  11. ; services (see: systemctl --user list-unit-files '*.service').
  12. ;
  13. ; The file must have a ".service" suffix but you may omit that suffix in the various
  14. ; commands below, i.e. you can write "my-service" instead of "my-service.service".
  15. ; You cannot omit the suffix for other types of units (e.g. .timer or .path).
  16. ;
  17. ; Then, tell systemd to reload its configuration:
  18. ;   systemctl --user daemon-reload
  19. ;
  20. ; Start your service right now:
  21. ;   systemctl --user start my-service.service
  22. ;
  23. ; Check on the status of your service:
  24. ;   systemctl --user status my-service.service
  25. ;
  26. ; If that works, enable your service to start automatically:
  27. ;   systemctl --user enable my-service.service
  28. ;
  29. ; Make sure the systemd user instance for the "debian" user is started at boot,
  30. ; otherwise your service(s) will only run when you're logged in:
  31. ;   sudo loginctl enable-linger debian
  32. ; (you only need to do this once)
  33. ;
  34. ;
  35. ; Follow log output related to your service (use control-C to exit):
  36. ;   journalctl -f --user-unit=my-service.service
  37. ;
  38. ;
  39. ; For detailed information about the directives available in the [Unit]
  40. ; and [Install] sections of systemd units in general, see:
  41. ;   man systemd.unit
  42. ;
  43. ; For directives available in the [Service] section of service units, see:
  44. ;   man systemd.service        
  45. ;   man systemd.exec
  46. ;   man systemd.resource-control
  47.  
  48.  
  49. [Unit]
  50.  
  51. Description=My user service
  52.  
  53.  
  54. [Install]
  55.  
  56. ; When enabled, start service at startup
  57. WantedBy=default.target
  58.  
  59.  
  60. [Service]
  61.  
  62. ; If your script just does some setup and then exits, use Type=oneshot
  63. ; To create a service that remains running, use Type=simple
  64. Type=simple
  65.  
  66. ; By default the service runs in ~, but you can choose a different working dir:
  67. ;WorkingDirectory=~
  68.  
  69. ; Program to run (absolute path required):
  70. ExecStart=/home/debian/my-service.sh
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top