pm2 icon indicating copy to clipboard operation
pm2 copied to clipboard

Can pm2 restart every 10 seconds?

Open KaitaoQiu opened this issue 2 years ago • 1 comments

Hi guys, B/c pm2's config is using crontab to do restart task, and crontab is not able to do with second-level task, the minimal tick size for crontab is 1 minute. So can pm2 restart my process every X seconds? Thanks

KaitaoQiu avatar Jun 01 '22 09:06 KaitaoQiu

@KaitaoQiu

It should be possible by passing an extra parameter for seconds to --cron-restart (which is described at https://pm2.keymetrics.io/docs/usage/restart-strategies/ )

So try:

pm2 start app.js --cron-restart="*/10 * * * * *"

Plast note that this require version 5.2.0, not sure how it works before that.

Hexagon avatar Jul 06 '22 23:07 Hexagon