← 返回命令列表

Linux command

forever 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Start script as daemon

forever start [app.js]

Stop daemon

forever stop [app.js]

Stop all daemons

forever stopall

List running processes

forever list

Restart script

forever restart [app.js]

Start with log file

forever start -l [forever.log] -o [out.log] -e [err.log] [app.js]

说明

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.

参数

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.
-s, --silent
Run script silencing stdout and stderr.
-a, --append
Append to log files instead of overwriting.
--minUptime _ms_
Minimum uptime before considering a restart as a crash (default: 1000ms).
--killTree
Kill the entire child process tree on stop.

FAQ

What is the forever command used for?

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.

How do I run a basic forever example?

Run `forever start [app.js]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does start _script_ do in forever?

Start script as daemon.