Operations 9 min read

How to Turn Any Linux Process into a Managed Daemon with Supervisor

This guide explains how Supervisor, a Python‑based process manager, can convert ordinary command‑line programs into monitored daemons on Linux, compares it with nohup, setsid and screen, and provides step‑by‑step installation, configuration, and web‑interface setup instructions.

Open Source Tech Hub
Open Source Tech Hub
Open Source Tech Hub
How to Turn Any Linux Process into a Managed Daemon with Supervisor

Overview

Supervisor is a Python‑written, general‑purpose process management tool that turns a normal command‑line process into a background daemon, monitors its status, and automatically restarts it on failure.

It launches managed processes as child processes of the supervisor daemon using a fork/exec model, so you only need to specify the executable path in the supervisor configuration file.

The tool can also capture detailed exit information, optionally trigger alerts, and run each managed process under a non‑root user.

Typical Scenarios

Running a program in the background on Linux.

Keeping a program alive after the terminal is closed.

Running a program as a daemon over an SSH session.

Advantages Compared to Other Tools

nohup : only detaches a command; lacks automatic restart and status monitoring, whereas Supervisor provides both and a convenient supervisorctl interface.

setsid : creates a new session but does not offer centralized management; Supervisor can start, stop, and monitor multiple processes together.

screen : provides a virtual terminal for interactive sessions; Supervisor focuses on automated process control, logging, and restart capabilities.

Installation (Ubuntu 20.04 Example)

Step 1 – Update Package Index

apt-get update -y

Step 2 – Install Supervisor

Supervisor is available in the default Ubuntu repositories. apt-get install supervisor -y Verify the installed version: supervisord -v Check the service status:

sudo systemctl status supervisor

Step 3 – Enable the Web Interface

Edit /etc/supervisor/supervisord.conf and add:

[inet_http_server]
port=*:9001
username=admin
password=admin

Restart the service to apply the changes:

systemctl restart supervisor

Step 4 – Manage a Redis Queue Process

Create a program configuration file, e.g., /etc/supervisor/conf.d/think-redis-queue.conf:

[program:think-redis-queue]
command=/usr/local/php-8.3.7/bin/php /home/www/website/train.tinywan.com/think redis-queue consumer
autostart=true
autorestart=true
startretries=5
numprocs=1
startsecs=0
process_name=%(program_name)s_%(process_num)02d
stderr_logfile=/var/log/supervisor/%(program_name)s_stderr.log
stderr_logfile_maxbytes=10MB
stdout_logfile=/var/log/supervisor/%(program_name)s_stdout.log
stdout_logfile_maxbytes=10MB

Reload the configuration and start the program:

sudo supervisorctl reread
sudo supervisorctl update

Check that the process is running:

sudo supervisorctl status think-redis-queue:think-redis-queue_00

Stop or start the process with:

supervisor> stop think-redis-queue:think-redis-queue_00
supervisor> start think-redis-queue:think-redis-queue_00

Step 5 – Access the Web Interface

Supervisor Web UI
Supervisor Web UI
Nginx configuration for proxying the Supervisor web UI: <code>server { listen 443 ssl http2; server_name supervisor.tinywan.cn; ssl_certificate /home/www/.acme.sh/supervisor.tinywan.cn/supervisor.tinywan.cn.cer; ssl_certificate_key /home/www/.acme.sh/supervisor.tinywan.cn/supervisor.tinywan.cn.key; location / { proxy_pass http://0.0.0.0:9001; proxy_buffering off; } }</code>

Common Supervisor Commands

supervisorctl status            // view status of all processes
supervisorctl stop es           // stop a specific process
supervisorctl start es          // start a specific process
supervisorctl restart es        // restart a specific process
supervisorctl update            // reload changed configuration files
supervisorctl reload            // restart all programs with new config

CentOS Installation

Install

yum install supervisor

Configuration File

/etc/supervisord.conf

Include Directory

[include]
files = supervisord.d/*.ini

Example Program Config (redis-queue-order-consumer.ini)

[program:redis-queue-order-consumer]
command=/usr/local/php-8.4/bin/php /home/wwwroot/order.tinywan.com/think redis-queue order-consumer
user=www
autostart=true
autorestart=true
startretries=5
numprocs=1
startsecs=0
process_name=%(program_name)s_%(process_num)02d
stderr_logfile=/var/log/supervisor/%(program_name)s_stderr.log
stderr_logfile_maxbytes=10MB
stdout_logfile=/var/log/supervisor/%(program_name)s_stdout.log
stdout_logfile_maxbytes=10MB

Supervisorctl Command

supervisorctl

View Service Status

supervisor> status
redis-queue-live-consumer:redis-queue-order-consumer_00   RUNNING   pid 1692927, uptime 0:16:17

Stop a specific service: stop all Start all services:

start all
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxSupervisorWeb Interface
Open Source Tech Hub
Written by

Open Source Tech Hub

Sharing cutting-edge internet technologies and practical AI resources.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.