'How can I completely stop a pm2 managed application?

Say I have a pm2 process that runs every 5 minutes and takes less than a second to run:

pm2 start ./some-node-script.js --name some-node-script --cron "*/5 * * * *" --no-autorestart

Now say I want to completely stop execution of the job. If I issue pm2 stop some-node-script, I get this warning:

[PM2][WARN] App some-node-script stopped but CRON RESTART is still UP */5 * * * *

And then the job executes again on the next 5 minute interval. Is there a way I can stop the cron job from executing again? I've tried pm2 kill, but that kills every job being managed by pm2.



Solution 1:[1]

To disable cron restart:

pm2 restart app_id --cron-restart 0

Then you can just

pm2 stop app_id

It will save app id.

https://pm2.keymetrics.io/docs/usage/restart-strategies/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user1852788