LinuxCommandLibrary

forever

TLDR

Start script as daemon

$ forever start [app.js]
copy
Stop daemon
$ forever stop [app.js]
copy
Stop all daemons
$ forever stopall
copy
List running processes
$ forever list
copy
Restart script
$ forever restart [app.js]
copy
Start with log file
$ forever start -l [forever.log] -o [out.log] -e [err.log] [app.js]
copy

SYNOPSIS

forever [options] command [script] [args]

DESCRIPTION

forever runs Node.js scripts continuously, restarting them automatically if they crash. It's designed for production deployment of Node.js applications, ensuring applications stay running.
The tool monitors processes and restarts them on exit. It supports logging, multiple instances, and can watch files for development auto-restart.

PARAMETERS

start script

Start script as daemon.
stop script|pid|index
Stop running process.
stopall
Stop all processes.
restart script|pid|index
Restart process.
restartall
Restart all processes.
list
List running processes.
logs script|pid|index
Show log files.
-l logfile
Log file for forever output.
-o outfile
Stdout log file.
-e errfile
Stderr log file.
-w, --watch
Watch for file changes.
-m max
Maximum restarts.

CAVEATS

Node.js only. Consider PM2 for production use (more features). Log files can grow large. Watch mode may miss some changes. Process management is basic compared to alternatives.

HISTORY

forever was created by Charlie Robbins and the Nodejitsu team in the early 2010s as one of the first process managers for Node.js. While PM2 has largely replaced it for production use, forever remains simple and functional.

SEE ALSO

pm2(1), nodemon(1), node(1), systemd(1)

Copied to clipboard