forever
Run Node.js scripts continuously in the background
TLDR
Start running a file forever (as a daemon)
List running "forever" processes (along with IDs and other details of "forever" processes)
Stop a running "forever" process
SYNOPSIS
forever [action] [options] [script] [args]
PARAMETERS
-a, --append
Append to log files instead of truncating
-c, --command CMD
Node binary to use (default: 'node')
-d, --debug
Enable debug output
-e, --errorLog FILE
Log errors to FILE
-f, --foreground
Run in foreground (no daemon)
-i, --uid UID
Run as specific user UID/GID
-l, --logFile FILE
General log file location
-m, --max N
Max restarts before giving up (default: 5)
-n, --number N
Number of process instances (default: 1)
-o, --outLog FILE
Log stdout to FILE
-p, --pidFile DIR
PID files directory (default: ~/.forever)
-s, --silent
Suppress all output except errors
-t, --time N
Time between restarts in ms (default: 5000)
-v, --version
Print version
-h, --help
Show help
DESCRIPTION
Forever is a Node.js command-line tool designed to keep server processes running indefinitely, automatically restarting them if they crash or exit unexpectedly.
It is particularly useful for deploying long-running applications like web servers, APIs, or background workers on production systems. Forever monitors the process, handles restarts with configurable limits, and provides logging for stdout, stderr, and errors.
Unlike simple solutions like nohup, forever offers clustering support, multiple instances, UID switching for security, and a dashboard-like list command to monitor running processes. It daemonizes by default but can run in foreground for development.
Installation is via npm: npm install -g forever. Common workflow: forever start app.js. Logs are stored in ~/.forever by default. It's lightweight but has been largely superseded by more feature-rich alternatives like PM2.
CAVEATS
Requires Node.js/npm; not a core system tool. PID files can conflict if not managed. Avoid root execution for security. Limited clustering compared to PM2.
ACTIONS
start, stop <id>, stopall, list [-p], restart <id>, restartall, clearlogs
EXAMPLE
forever start -o out.log -e err.log server.js --port=3000
HISTORY
Created by Charlie Robbins in 2010 as part of Nodejitsu's Flatiron Web Framework suite. Gained popularity for simple process management. Maintained on GitHub; last major updates around 2018, now in maintenance mode.


