Operations 5 min read

Using Supervisor to Manage and Auto‑Restart Python Scripts on Linux

This tutorial explains how to install Supervisor on CentOS and Ubuntu, configure its main and program-specific files, and use it to monitor a continuously running Python script, automatically restarting the script if it crashes or is killed.

360 Tech Engineering
360 Tech Engineering
360 Tech Engineering
Using Supervisor to Manage and Auto‑Restart Python Scripts on Linux

Supervisor is a Python‑based client/server daemon for Unix‑like systems that monitors and automatically restarts managed processes.

The article first explains why simple nohup cannot monitor or restart scripts, then introduces Supervisor, its compatibility with Python 2.7/3.4+, and its installation methods on CentOS (yum) and Ubuntu (apt), as well as Python package installation via pip or easy_install.

It describes the required configuration files: supervisord.conf for the daemon and separate .ini files for each managed program, showing typical locations (/etc/, /etc/supervisord.d) and how to generate a default config with echo_supervisord_conf >> supervisord.conf.

A practical example creates a simple hello.py script that repeatedly prints “hello world”, places it under /home/yz/supervisor_study/, and configures both the daemon and a program section ( hello.ini) to log output to a project‑specific logs directory.

After starting Supervisor with supervisord and controlling the program via supervisorctl, the article shows that killing the Python process results in Supervisor automatically restarting it, confirming the auto‑restart feature.

Finally, common Supervisor commands for starting, stopping, and reloading configurations are listed, and a link to the official documentation is provided.

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.

PythonautomationOperationsLinuxSupervisorprocess monitoring
360 Tech Engineering
Written by

360 Tech Engineering

Official tech channel of 360, building the most professional technology aggregation platform for the brand.

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.