Skip to content
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

cron doesn't work #1278

Closed
webjay opened this issue May 15, 2015 · 5 comments
Closed

cron doesn't work #1278

webjay opened this issue May 15, 2015 · 5 comments
Labels

Comments

@webjay
Copy link

webjay commented May 15, 2015

I would expect the below PM2 configuration to restart run.js every second of every minute of every hour Fridays and Saturdays and Sundays and Mondays in every month.

But it doesn't.

{
  "name": "cronthis",
  "script": "run.js",
  "cron_restart": "* * * * * 5,6,0,1"
}

Even using normal cron standard * * * * 5,6,0,1, it doesn't restart.

Am I missing something or is that a known bug?

@webjay
Copy link
Author

webjay commented May 15, 2015

I have tested with ncb000gt/node-cron where my pattern works.

@ravi
Copy link

ravi commented May 15, 2015

See #496 #662.

@rachel-benh
Copy link

rachel-benh commented Sep 13, 2016

Hi,
I created the following config:
{
"apps": [
{
"name": "temp",
"script": "./scripts/temp1.js",
"watch": false,
"merge_logs": true,
"exec_mode": "fork_mode",
"error_file": "./server.log",
"out_file": "./server.log",
"cwd": "./myDevl",
"cron_restart": "* * * * *",
"exec_interpreter": "node",
"autorestart" : false,
"env": {
"EXTERNAL_CONFIG_SOURCE": "file",
"EXTERNAL_CONFIG_LOCATION": "local_cfg.json",
"NODE_ENV": "hellow",
"TEST": true
},
"pmx": false,
"vizion": false
}]
}
The script runs just once. After running i get a message that the process exited.
Thanks
Rachel

@ravi
Copy link

ravi commented Sep 13, 2016

@rachel-benh @webjay my new understanding of how this feature works is that the emphasis is on the restart part i.e., PM2 expects your process to not end. It will restart the process at the specified cron intervals if it is running, and fallback to standard restart logic if the process exits. In other words, this is not a 100% replacement for Unix cron. Caveat emptor: I may be wrong on that.

@stale
Copy link

stale bot commented May 24, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 24, 2020
@stale stale bot closed this as completed Jun 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants