Last active
July 2, 2025 14:02
-
-
Save wwwqr-000/68d540739fd05b9109fd6f05634e2f6e to your computer and use it in GitHub Desktop.
daemon_process_linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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