I'm using the --cron flag to run a job every hour. The issue is as soon as I deploy using pm2 deploy. I see in the logs it's running the job every second.
apps: [
{
name: "api",
script: "./index.js",
autorestart: true
},
{
name: "cron",
script: "./cron.js --cron '0 * * * *'"
}
],
The cron syntax seems to be correct, am I missing something else?
The way to properly create a cronjob with pm2 is:
pm2 start index.js --no-autorestart --cron "*/15 * * * *" --name "My 15m cron job"
If passing arguments is needed then:
pm2 start index.js --no-autorestart --cron "*/15 * * * *" --name "My 15m cron job" -- --cron-15m
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.