Skip to content

Instantly share code, notes, and snippets.

@wwwqr-000
Last active July 2, 2025 14:02
Show Gist options
  • Select an option

  • Save wwwqr-000/68d540739fd05b9109fd6f05634e2f6e to your computer and use it in GitHub Desktop.

Select an option

Save wwwqr-000/68d540739fd05b9109fd6f05634e2f6e to your computer and use it in GitHub Desktop.
daemon_process_linux
#A daemon process runs your command/ application in the background. This gist explains on how to set it up and use it.
sudo -s
cd /etc/systemd/system/
nano custom-daemon.service
#Begin file
[Unit]
Description=Custom daemon process
After=network.target
[Service]
User=username
WorkingDirectory=/directory/of/workspace
ExecStart=/bin/sh /directory/of/workspace/run.sh
Restart=always
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
#End file
#Give the "Description" a description to your likings.
#For the user, enter the user you want to link to the daemon-process
systemctl daemon-reexec
systemctl enable --now custom-daemon.service
#You can run the following command to check the status of the service
systemctl status custom-daemon
#If you are getting errors, check for username, execution premissions and correct working directory.
#To reload the daemons, use the following command: systemctl daemon-reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment