Skip to content

Instantly share code, notes, and snippets.

@saradindusengupta
Last active November 9, 2023 10:34
Show Gist options
  • Save saradindusengupta/9307aa32590907411ceba9a3826e23b0 to your computer and use it in GitHub Desktop.
Save saradindusengupta/9307aa32590907411ceba9a3826e23b0 to your computer and use it in GitHub Desktop.
Sample systemd service file and how to setup systemd

Sample systemd service file and how to setup systemd

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
PIDFile=/run/nginx.pid
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
User=$USER
PrivateTmp=true
Type=notify
Restart=always

[Install]
WantedBy=multi-user.target
RequiredBy=network.target
  1. Copy the sample.service file to /etc/systemd/system/
  2. Run sudo systemctl daemon-reload
  3. Run sudo systemctl enable sample.service
  4. Run sudo systemctl is-enabled sample.service to check if the service file is enabled or not

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment