Currently the cron_restart option only works for online processes ([[1](https://github.com/Unitech/pm2/blob/master/lib/ProcessContainer.js#L92)][[2](https://github.com/Unitech/pm2/blob/master/lib/ProcessContainerFork.js#L19])])
That logic should be moved to the Worker so It can restart offline applications (useful when used with autorestart to false)
+1
Also looking for this feature. Has there been any movement on it?
Any news on this feature ?
Any news?
Does this also cause memory to not be released? I have a node program which is being run every hour using pm2 cron, and it completes after about 20 seconds. However for the rest of the hour, pm2 list shows it as taking up ~50mb of memory.
My workaround while this isn't fixed:
bin/job that will execute your script for example:#!/usr/bin/env node
const { exec } = require('child_process')
exec(process.argv.slice(2).join(' '), function (error, stderr, stdout) {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
})
// fake long running process
setInterval(() => {}, 1e6)
{
"name": "cron_compute_midnight",
"script": "./bin/job",
"exec_mode": "fork",
"args": "curl -s http://localhost/api/batch/compute",
"cron_restart": "0 0 * * *"
}
Obviously, if this issue were to be fixed the following would work:
{
"name": "cron_compute_midnight",
"script": "curl",
"exec_mode": "fork",
"args": "-s http://localhost/api/batch/compute",
"cron_restart": "0 0 * * *",
"autorestart": false
}
Most helpful comment
Also looking for this feature. Has there been any movement on it?