Pm2: cron option is broken

Created on 14 Dec 2018  路  3Comments  路  Source: Unitech/pm2

What's going wrong?

[email protected]

--cron option may be broken. On setting --cron option, pm2 restarts repeatedly ignoring cron schedule.

How could we reproduce this issue?

$ 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.

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

All 3 comments

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)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lefam picture lefam  路  3Comments

ghost picture ghost  路  3Comments

liujb picture liujb  路  3Comments

bragma picture bragma  路  4Comments

rangercyh picture rangercyh  路  4Comments