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?
I have tested with ncb000gt/node-cron where my pattern works.
See #496 #662.
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
@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.
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.
Most helpful comment
@rachel-benh @webjay my new understanding of how this feature works is that the emphasis is on the
restartpart 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.