'PM2 only auto restart between specific time?

Not sure how to make pm2 run a Javascript that restart at 23 PM 59 sec everyday then enables auto restart for 10 mins to next day's 00:09 then no-autorestart for the rest of the day until reaching 23:59 again...

Only able to set it to restart at 23:59 but with no autorestart: pm2 start index.js --no-autorestart --cron "59 23 */1 * *"

How can I make it then auto restart between 23:59 until 00:09 then return back to no-autorestart setting?



Solution 1:[1]

Found out that using pm2 will cause the script to crash (Used for creating Discord bot, When using pm2 the script will crash and immediately restarted by pm2 then Discord will reset token if connect more than 1000 times, causing the script to not be able to run automatically) but the issue was fixed by switching to forever npm.

https://www.npmjs.com/package/forever

Solution 2:[2]

$ pm2 start app.js --cron-restart="0 0 * * *" This will auto-restart your application at midnight (this uses your system time).

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 Peanut Jams
Solution 2 Liam