--cron option may be broken. On setting --cron option, pm2 restarts repeatedly ignoring cron schedule.
$ pm2 -v
3.2.3
$ pm2 start app.js --cron '00 00 10 * *'
in app.js
// Any scripts ok
console.log('start')
setTimeout(() => console.log('done'), 2000)
will restarts app repeatedly.
it seems like autorestart must be false now. for me, if it is unset or true it will restart forever.
try 'autorestart: false,' or '--no-autorestart'
https://github.com/Unitech/pm2/pull/3944
https://github.com/Unitech/pm2/commit/92112f9ab72e7a813124e55d0e54f93ca29c7693
https://github.com/Unitech/pm2/commit/97d73b456ac8d5d6cd06e3b45f2edd832bebb6f7
Thank you @SoSafeSec .
It works for me below.
pm2 start --cron '* * * * *' --no-autorestart app.js
It's a little confusing that one should use --no-autorestart option whenever he uses --cron option.
The --cron is more intended to force a restart (e.g. you want to force the app to restart every midnight to keep the node.js context clean)
Most helpful comment
it seems like autorestart must be false now. for me, if it is unset or true it will restart forever.
try 'autorestart: false,' or '--no-autorestart'
https://github.com/Unitech/pm2/pull/3944
https://github.com/Unitech/pm2/commit/92112f9ab72e7a813124e55d0e54f93ca29c7693
https://github.com/Unitech/pm2/commit/97d73b456ac8d5d6cd06e3b45f2edd832bebb6f7