-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pm2 cron schedule starts immediately, but it should start next morning instead #5479
Comments
Using the --cron option tells it at what time you want it to restart, not what time you want it to start at. |
Thank you for the explanation. |
Same question |
Came here with the same issue. There should be an option that prevents the initial run from occurring, e.g. "just schedule, do not run now". |
there is no option for this as far as I know. But I have added the following condition to index.js itself when I had similar requirement:
this will stop the process immediately but it still will be restarted by cron. Note you should also disable autorestart (--no-autorestart) After the subsequent start on the script Not ideal, but works in my case. |
I'm going through the issues to find mentions about not auto-starting a new process, which I now created a PR for: |
Feature landed Update PM2 to 5.4.0 $ npm install pm2@5.4.0 -g
$ pm2 update |
What's going wrong?
I set up the cron job like "*pm2 start index.js --cron '00 06 * * ' --no-autorestart" at 4pm and I expected pm2 to start the next morning at 6AM, but it immediately starts the node script. Is this intended that it "knows" it's after 6AM so just start it?
How could we reproduce this issue?
"pm2 start index.js --cron '00 06 * * *' --no-autorestart"
Supporting information
I use pm2 5.2.2 on my newest Raspberry Pi (v4) version (standard OS)
The text was updated successfully, but these errors were encountered: