Operations 6 min read

Using Supervisor for Process Management on Linux: Installation, Configuration, and Practical Example

This article explains why nohup cannot monitor scripts, introduces Supervisor as a Python‑based process monitor, shows how to install it on CentOS, Ubuntu, and via pip, details the supervisord.conf and program .ini configurations, demonstrates a sample Python script, and outlines common commands for managing and restarting services.

360 Quality & Efficiency
360 Quality & Efficiency
360 Quality & Efficiency
Using Supervisor for Process Management on Linux: Installation, Configuration, and Practical Example

Running scripts with nohup keeps them alive after the terminal closes, but it provides no monitoring or automatic restart capabilities.

Supervisor, a Python‑written client/server tool, fills this gap on Unix‑like systems by managing child processes, restarting them on failure, and offering control via supervisord and supervisorctl . It supports Python 2.7 and 3.4+.

Installation methods include using the system package manager ( yum on CentOS, apt on Ubuntu) or installing via pip or easy_install .

Supervisor’s main configuration file is supervisord.conf , searched in several default locations unless overridden with the -c option. The default file is placed under /etc/ when installed via the package manager.

Typical supervisord.conf sections define the log directory, the directory for program configuration files (default /etc/supervisord.d ), and other global settings. You can generate a default file with echo_supervisord_conf >> supervisord.conf if it does not exist.

In the practical example, a simple Python script /home/yz/supervisor_study/hello.py continuously prints “hello world”. A program configuration file ( hello.ini ) is placed in the project directory and referenced from supervisord.conf . The example also shows how to redirect Supervisor’s own logs to a project‑specific logs folder.

After editing supervisord.conf , start Supervisor with supervisord and manage programs with supervisorctl . The logs directory will contain the program log ( hello.* ) and the Supervisor log ( supervisor.log ).

A test of killing the Python process (e.g., kill -9 22917 ) demonstrates that Supervisor automatically restarts the process with a new PID, confirming its auto‑restart feature.

Common Supervisor commands (shown in an image in the original article) include starting, stopping, restarting Supervisor and individual programs, and reloading configuration.

For more details, refer to the official documentation at http://www.supervisord.org/ .

PythonAutomationoperationsconfigurationprocess managementlinuxSupervisor
360 Quality & Efficiency
Written by

360 Quality & Efficiency

360 Quality & Efficiency focuses on seamlessly integrating quality and efficiency in R&D, sharing 360’s internal best practices with industry peers to foster collaboration among Chinese enterprises and drive greater efficiency value.

0 followers
Reader feedback

How this landed with the community

login 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.