admin管理员组

文章数量:1429953

I am scheduling a script to run every minute using the following command:

pm2 start my-script.js --cron "* * * * *"

This does make the script run every minute, but here is the issue - if the first run of the script takes more than one minute, it seems like PM2 is killing that instance and starting a new one. This script finishes within seconds most of the time but it sometimes needs to run for a few minutes. I expected PM2 to simply run a new instance of the script after a minute has elapsed and let the previous run finish.

I have some logs from this script showing time elapsed every 5 seconds. Checking the live logs for the script with pm2 logs my-script shows that logs from the first run of the script suddenly stop when the second run starts.

How can I tell pm2 to start another instance of the script concurrently if the previous run has not finished yet?

本文标签: javascriptPM2 running script instances concurrentlyStack Overflow