SHARE
TWEET

Untitled

silver2row Sep 11th, 2019 118 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;;; systemd system service example
  2. ; See also https://pastebin.com/uqY2DcGs for a user service example.
  3. ;
  4. ; Save as this file:  /etc/systemd/system/my-service.service
  5. ;
  6. ; You can use any name instead of "my-service" of course (but then also adjust that
  7. ; in the commands below), as long as it doesn't conflict with any existing system
  8. ; services (see: systemctl list-unit-files '*.service').
  9. ;
  10. ; The file must have a ".service" suffix but you may omit that suffix in the various
  11. ; commands below, i.e. you can write "my-service" instead of "my-service.service".
  12. ; You cannot omit the suffix for other types of units (e.g. .timer or .path).
  13. ;
  14. ; Then, tell systemd to reload its configuration:
  15. ;   sudo systemctl daemon-reload
  16. ;
  17. ; Start your service right now:
  18. ;   sudo systemctl start my-service.service
  19. ;
  20. ; If that works, enable your service to start at boot:
  21. ;   sudo systemctl enable my-service.service
  22. ;
  23. ;
  24. ; Follow log output related to your service (use control-C to exit):
  25. ;   journalctl --follow --unit=my-service.service
  26. ; which you can also abbreviate to:
  27. ;   journalctl -f -u my-service
  28. ;
  29. ;
  30. ; For detailed information about the directives available in the [Unit]
  31. ; and [Install] sections of systemd units in general, see:
  32. ;   man systemd.unit
  33. ;
  34. ; For directives available in the [Service] section of service units, see:
  35. ;   man systemd.service        
  36. ;   man systemd.exec
  37. ;   man systemd.resource-control
  38.  
  39.  
  40. [Unit]
  41.  
  42. Description=My system service
  43.  
  44. ; It may be necessary to include dependencies to prevent the script from
  45. ; running too early during boot.
  46.  
  47. ; For example, if you need networking, you probably want:
  48. Wants=network-online.target
  49. After=network-online.target
  50.  
  51. ; If you need stuff in /dev, you probably want:
  52. Wants=systemd-udev-settle.service
  53. After=systemd-udev-settle.service
  54.  
  55.  
  56. [Install]
  57.  
  58. ; When enabled, start service at boot
  59. WantedBy=multi-user.target
  60.  
  61.  
  62. [Service]
  63.  
  64. ; If your script just does some setup and then exits, use Type=oneshot
  65. ; To create a service that remains running, use Type=simple
  66. Type=simple
  67.  
  68. ; By default the service runs as root, but you can choose a different user:
  69. User=debian
  70.  
  71. ; By default the service runs in /, but you can choose a different working dir:
  72. WorkingDirectory=/home/debian
  73.  
  74. ; Program to run (absolute path required):
  75. 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