How to run a linux process in the background
Run a process in the background by adding an ampersand &
to the end of a command.
./run.sh&
List background processes
jobs
Stop a background process
kill
Move a background process to the foreground
fg
send the current process to the background
bg
Run services in the background even after logout
Create a SystemD Service
/etc/systemd/myservice.service
[Unit]
Description=Apache Web Server
[Service]
Type=simple
ExecStart=/usr/sbin/httpd -k start
ExecStop=/usr/sbin/httpd -k stop
[Install]
WantedBy=multi-user.target
References:
- https://akashrajpurohit.com/blog/keep-your-services-running-in-the-background-with-systemd/#:~:text=Do%20you%20want%20your%20Linux%20services%20to,and%20stop%20it%2C%20and%20monitor%20its%20status