pm2 icon indicating copy to clipboard operation
pm2 copied to clipboard

pm2 cron stops running tasks

Open Dejw4g opened this issue 6 years ago • 2 comments

What's going wrong?

task scheduled using cron function stops running after some time

How could we reproduce this issue?

I don't know ho to reproduce it directly, but it always happens after some time (days).

I create the task like this: pm2 start index.js --name auto-dnd --watch --time --cron "*/5 * * * *" --no-autorestart

and here is the log: running auto-dnd: 2020-8-28 11:7:27 running auto-dnd: 2020-8-28 11:10:3 running auto-dnd: 2020-8-28 11:15:2 running auto-dnd: 2020-8-28 11:20:1 running auto-dnd: 2020-8-31 14:15:29 running auto-dnd: 2020-8-31 14:20:0

where the log from 31.8. happened after manually reloading the task - it was dead without it. PM2 and the script is running on my macbook pro, so the machine doesn't run 24/7 - but for most of the time it manages to continue normally after opening up the macbook and start using it - but then, for some unknown reason, it stops running...

Supporting information

--- PM2 report ----------------------------------------------------------------
Date                 : Mon Aug 31 2020 15:47:20 GMT+0200 (Central European Summer Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 4.4.1
node version         : 10.20.1
node path            : /Users/dejw/.nvm/versions/node/v10.20.1/bin/pm2
argv                 : /Users/dejw/.nvm/versions/node/v10.20.1/bin/node,/Users/dejw/.nvm/versions/node/v10.20.1/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : dejw
uid                  : 501
gid                  : 20
uptime               : 26min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 4.4.1
node version         : 10.20.1
node path            : /Users/dejw/.nvm/versions/node/v10.20.1/bin/pm2
argv                 : /Users/dejw/.nvm/versions/node/v10.20.1/bin/node,/Users/dejw/.nvm/versions/node/v10.20.1/bin/pm2,report
argv0                : node
user                 : dejw
uid                  : 501
gid                  : 20
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : darwin
type                 : Darwin
cpus                 : Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
cpus nb              : 4
freemem              : 641970176
totalmem             : 17179869184
home                 : /Users/dejw
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬─────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name        │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼─────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ auto-dnd    │ default     │ N/A     │ fork    │ 0        │ 0      │ 0    │ stopped   │ 0%       │ 0b       │ dejw     │ enabled  │
└─────┴─────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/Users/dejw/.pm2/pm2.log last 20 lines:
PM2        | 2020-08-31T15:25:00: PM2 log: Process 0 in a stopped status, starting it
PM2        | 2020-08-31T15:25:00: PM2 log: App [auto-dnd:0] starting in -fork mode-
PM2        | 2020-08-31T15:25:00: PM2 log: App [auto-dnd:0] online
PM2        | 2020-08-31T15:25:06: PM2 log: App [auto-dnd:0] exited with code [0] via signal [SIGINT]
PM2        | 2020-08-31T15:30:00: PM2 log: Process 0 in a stopped status, starting it
PM2        | 2020-08-31T15:30:00: PM2 log: App [auto-dnd:0] starting in -fork mode-
PM2        | 2020-08-31T15:30:00: PM2 log: App [auto-dnd:0] online
PM2        | 2020-08-31T15:30:03: PM2 log: App [auto-dnd:0] exited with code [0] via signal [SIGINT]
PM2        | 2020-08-31T15:35:00: PM2 log: Process 0 in a stopped status, starting it
PM2        | 2020-08-31T15:35:00: PM2 log: App [auto-dnd:0] starting in -fork mode-
PM2        | 2020-08-31T15:35:00: PM2 log: App [auto-dnd:0] online
PM2        | 2020-08-31T15:35:03: PM2 log: App [auto-dnd:0] exited with code [0] via signal [SIGINT]
PM2        | 2020-08-31T15:40:00: PM2 log: Process 0 in a stopped status, starting it
PM2        | 2020-08-31T15:40:00: PM2 log: App [auto-dnd:0] starting in -fork mode-
PM2        | 2020-08-31T15:40:00: PM2 log: App [auto-dnd:0] online
PM2        | 2020-08-31T15:40:03: PM2 log: App [auto-dnd:0] exited with code [0] via signal [SIGINT]
PM2        | 2020-08-31T15:45:00: PM2 log: Process 0 in a stopped status, starting it
PM2        | 2020-08-31T15:45:00: PM2 log: App [auto-dnd:0] starting in -fork mode-
PM2        | 2020-08-31T15:45:00: PM2 log: App [auto-dnd:0] online
PM2        | 2020-08-31T15:45:03: PM2 log: App [auto-dnd:0] exited with code [0] via signal [SIGINT]

Dejw4g avatar Aug 31 '20 13:08 Dejw4g

In my case task are never run, cron param seems to be ignored (I am using 4.5.0 version of PM2)

here is my configuration

      name: "***",
      script: "index.js",
      env: {},
      instances: 1,
      exec_mode: "fork",
      output: "/logs/pm2/***-out.log",
      error: "/logs/pm2/***-error.log",
      merge_logs: true,
      cron_restart: "0 0 * * SUN",
      watch: false,
      autorestart: false
    }```

mlecoq avatar Oct 12 '20 09:10 mlecoq

fixed in [email protected]:

npm install pm2@latest -g
pm2 update

Unitech avatar Dec 16 '20 14:12 Unitech