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

pm2 cron stops running tasks #4834

Closed
Dejw4g opened this issue Aug 31, 2020 · 2 comments
Closed

pm2 cron stops running tasks #4834

Dejw4g opened this issue Aug 31, 2020 · 2 comments

Comments

@Dejw4g
Copy link

Dejw4g commented Aug 31, 2020

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]

@mlecoq
Copy link

mlecoq commented Oct 12, 2020

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
    }```

@Unitech
Copy link
Owner

Unitech commented Dec 16, 2020

fixed in pm2@4.5.1:

npm install pm2@latest -g
pm2 update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants