On this page
Key takeaways
- systemd is the Linux-native way to run, restart, and enable services on boot.
- supervisord supervises long-running processes with simple config and logging.
- PM2, nodemon, and Forever keep Node.js apps alive, each at a different level.
- Foreman runs a group of processes together, while WinSW wraps programs as Windows services.
A background job that dies quietly is one of the more annoying failures in development and production alike. Processes need to start on their own, stay up through errors, and restart when the machine reboots. Doing that by hand means babysitting terminals, which does not scale past the first or second service.
The tools below manage long-running processes at different levels, from the operating system to a single Node.js project. Some supervise a whole fleet of services, some watch one script and restart it on changes, and some wrap programs into proper background services. The right choice depends on what you are keeping alive and where it runs.
Quick comparison
| Tool | Best for | Starting price | Free plan |
|---|---|---|---|
| supervisord | Managing long-running processes | Not included | Not included |
| systemd | Service management on Linux | Not included | Not included |
| PM2 | Process management for Node.js | Not included | Not included |
| nodemon | Restarting Node.js on changes | Not included | Not included |
| Forever | Keeping Node.js scripts running | Not included | Not included |
| Foreman | Running process groups | Not included | Not included |
| WinSW | Running programs as Windows services | Not included | Not included |
The best tools for managing background jobs in the terminal
1. supervisord
- Official site: https://supervisord.org/
- Best for: Managing long-running processes
- Starting price: Not included
- Free plan: Not included
- Pros: Auto-restarts crashed jobs; Central logs and control UI
- Cons: Not a full init system; Python-based setup
supervisord is a process supervisor that starts, monitors, and restarts long-running programs according to a simple configuration file. Each job gets a name, a command, and rules for what happens when it exits, and the supervisor collects the output into logs. A small control interface lets an operator start, stop, and check jobs without hunting for PIDs.
It is best for running several worker processes or small services on a server without a full init system, especially in containers. supervisord restarts a job that crashes and groups related processes together. The trade-off is that it is an application-layer supervisor, so it does not replace systemd for things like boot order and dependency management.
2. systemd
- Official site: https://systemd.io/
- Best for: Service management on Linux
- Starting price: Not included
- Free plan: Not included
- Pros: Native boot and restart handling; Rich dependency and logging support
- Cons: Linux only; Unit files take time to learn
systemd is the init and service manager on most Linux distributions. A unit file describes a service, its command, and its dependencies, and systemd starts it at boot, restarts it on failure, and collects its logs through the journal. Because it is part of the operating system, it handles ordering and cleanup that a separate supervisor cannot.
It is best for services that must survive reboots and run as first-class parts of the system. systemd is the standard for production Linux servers, so a service that works there is portable across distributions and easy for other administrators to understand. The cost is the Linux-only scope and the time needed to write correct unit files.
3. PM2
- Official site: https://pm2.keymetrics.io/
- Best for: Process management for Node.js
- Starting price: Not included
- Free plan: Not included
- Pros: Cluster mode and reloads; Built-in monitoring and logs
- Cons: Focused on Node.js; Some features tied to a web dashboard
PM2 is a process manager for Node.js that keeps applications running, restarts them after crashes, and can spread them across CPU cores in cluster mode. It stores a list of apps, starts them all with one command, and provides logs and a live status view from the terminal. Zero-downtime reloads let a new version take over without dropping requests.
It is best for Node.js services that need to stay up on a server, especially when a team wants simple commands for start, stop, and restart. PM2 can also resurrect a saved process list on reboot, which covers the most common production need. Its main limits are the Node.js focus and the fact that some conveniences lead toward a paid dashboard.
4. nodemon
- Official site: https://nodemon.io/
- Best for: Restarting Node.js on changes
- Starting price: Not included
- Free plan: Not included
- Pros: Instant restarts in development; Watches files with rules
- Cons: Development tool, not for production; Only for Node.js
nodemon watches a Node.js project and restarts the process whenever a source file changes. During development it removes the manual stop and start loop, so a developer saves a file and the server picks up the change in a moment. Watch rules control which files trigger a restart and which are ignored.
It is best for local development, where the goal is a fast feedback loop rather than long-term stability. nodemon works well with frameworks and scripts that need a fresh process to load new code. It is not a production supervisor, so a deployed service should still be run under PM2, systemd, or a similar manager.
5. Forever
- Official site: https://github.com/foreverjs/forever
- Best for: Keeping Node.js scripts running
- Starting price: Not included
- Free plan: Not included
- Pros: Simple command-line control; Keeps scripts alive across failures
- Cons: Older project with less momentum; Basic feature set
Forever is a simple tool that keeps a Node.js script running and restarts it if it crashes. It stores a record of running scripts and can restart them all, list their status, and stream logs. The interface is minimal, which makes it easy to start with when the only requirement is that a process stays up.
It is best for small Node.js scripts and services where a full process manager would be more than needed. Forever covers the essential restart behavior with very few concepts to learn. The project is older and quieter than alternatives like PM2, so teams planning to scale usually reach for a more feature-rich manager.
6. Foreman
- Official site: https://github.com/ddollar/foreman
- Best for: Running process groups
- Starting price: Not included
- Free plan: Not included
- Pros: One command for many processes; Reads a simple Procfile
- Cons: Designed for development; Limited supervision features
Foreman runs a group of processes together by reading a Procfile that lists each command under a name. Instead of opening one terminal per worker, a developer types a single command and Foreman starts every process in the group, tagging each line of output with its source. The pattern is now common across other tools and platforms.
It is best for local development when an app needs a web server, a worker, and other services running at once. Foreman keeps the whole set in one window and stops them together, which removes the chore of managing several terminals. It is a development convenience, so production deployments still need a real supervisor underneath.
7. WinSW
- Official site: https://github.com/winsw/winsw
- Best for: Running programs as Windows services
- Starting price: Not included
- Free plan: Not included
- Pros: Wraps any program as a service; XML config with logging
- Cons: Windows only; Needs setup per application
WinSW is a wrapper that runs almost any program as a native Windows service. A small XML file describes the command, working directory, and logging, and WinSW handles start, stop, and restart through the standard Windows service controls. It also supports service recovery and running under a specific user account.
It is best for turning scripts and long-running programs into first-class Windows services that start on boot and restart after failure. WinSW fills the gap left by systemd on Windows, where no built-in equivalent exists for arbitrary programs. The setup is per application and Windows-only, but for that platform it is the standard answer.
How we chose
These tools were chosen to cover background jobs at every level where they need management, from a single script in development to a fleet of services in production. The list spans an operating system's own service manager, general process supervisors, Node.js-specific tools, and a Windows wrapper, because the correct tool depends on the platform and the stage of the work.
Preference went to actively maintained tools with clear documentation and a job that is easy to describe. Background management is about reliability, so the list favors tools that have been stable for years over ones with new and unproven features.
FAQ
What is the difference between supervisord and systemd?
systemd is the operating system's own service manager with boot and dependency handling, while supervisord is a separate supervisor better suited to containers and user-level process groups.
Which tool should I use for a production Node.js app?
PM2 is the most common choice, because it handles restarts, clusters, logs, and reloads, while systemd can run it as a system service underneath.
Is nodemon suitable for production?
No. nodemon is a development tool for restarting on file changes, so a deployed app should run under PM2, systemd, or supervisord instead.
Can Foreman replace a production process manager?
No, Foreman is meant for running a group of processes during development, so production still needs a real supervisor to keep each process alive.
How do I run a script as a Windows service?
Use WinSW, which wraps the script in a small XML config and exposes it through the normal Windows service controls, including boot start.