Open
Description
What's going wrong?
Cron tasks running through PM2 do not stat at system statup/reboot and i have to manually pm2 start x
them. I have a DNS-Updater task that runs every 30 minutes and this is the ecosystem file:
module.exports = {
apps : [{
name : "DNS-Updater",
namespace : "task",
script : "python3",
watch: false,
instances: 1,
args : "dnsupdater.py",
cron_restart : "*/30 * * * *",
autorestart : false
}]
}
I was forced to set autorestart : false
because otherwise every time the task stops it restarts so this causes it to run constantly instead of the scheduled cron.
I saw that in the new release 5.4.0 was added an autostart
#5782 but this won't work either because it does not trigger at system startup
PS. It might be very well that I'm using it in a wrong way, but honestly the docs aren't very clear
How could we reproduce this issue?
Create a cron task without autorestart, start it, reboot the system and it won't run ever until you first start it with pm2 start x
Supporting information
--- PM2 report ----------------------------------------------------------------
Date : Sat Jun 01 2024 10:17:23 GMT+0200 (Central European Summer Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version : 5.4.0
node version : 20.13.1
node path : /root/.nvm/versions/node/v20.13.1/bin/pm2
argv : /root/.nvm/versions/node/v20.13.1/bin/node,/root/.nvm/versions/node/v20.13.1/lib/node_modules/pm2/lib/Daemon.js
argv0 : node
user : root
uid : 0
gid : 0
uptime : 6min
===============================================================================
--- CLI ----------------------------------------------------
local pm2 : 5.4.0
node version : 20.13.1
node path : /root/.nvm/versions/node/v20.13.1/bin/pm2
argv : /root/.nvm/versions/node/v20.13.1/bin/node,/root/.nvm/versions/node/v20.13.1/bin/pm2,report
argv0 : node
user : root
uid : 0
gid : 0
===============================================================================
--- System info --------------------------------------------
arch : arm64
platform : linux
type : Linux
cpus : Cortex-A53
cpus nb : 4
freemem : 437067776
totalmem : 951398400
home : /root
===============================================================================
--- PM2 list -----------------------------------------------
┌────┬────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├────┼────────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0 │ DNS-Updater │ task │ N/A │ fork │ N/A │ 0 │ 0 │ stopped │ 0% │ 0b │ root │ disabled │
│ 1 │ HR-API │ api │ N/A │ fork │ 21632 │ 6m │ 0 │ online │ 0.6% │ 59.4mb │ root │ disabled │
│ 2 │ HR-Sync │ task │ N/A │ fork │ N/A │ 0 │ 0 │ stopped │ 0% │ 0b │ root │ disabled │
│ 3 │ PlexAPI │ api │ N/A │ fork │ 21633 │ 6m │ 0 │ online │ 0.1% │ 35.3mb │ root │ disabled │
│ 4 │ TelegramChatBot │ api │ N/A │ fork │ 21634 │ 6m │ 0 │ online │ 0% │ 42.0mb │ root │ disabled │
└────┴────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/root/.pm2/pm2.log last 20 lines:
PM2 | 2024-06-01T10:11:09: PM2 log: Node.js version : 20.13.1
PM2 | 2024-06-01T10:11:09: PM2 log: Current arch : arm64
PM2 | 2024-06-01T10:11:09: PM2 log: PM2 home : /root/.pm2
PM2 | 2024-06-01T10:11:09: PM2 log: PM2 PID file : /root/.pm2/pm2.pid
PM2 | 2024-06-01T10:11:09: PM2 log: RPC socket file : /root/.pm2/rpc.sock
PM2 | 2024-06-01T10:11:09: PM2 log: BUS socket file : /root/.pm2/pub.sock
PM2 | 2024-06-01T10:11:09: PM2 log: Application log path : /root/.pm2/logs
PM2 | 2024-06-01T10:11:09: PM2 log: Worker Interval : 30000
PM2 | 2024-06-01T10:11:09: PM2 log: Process dump file : /root/.pm2/dump.pm2
PM2 | 2024-06-01T10:11:09: PM2 log: Concurrent actions : 2
PM2 | 2024-06-01T10:11:09: PM2 log: SIGTERM timeout : 1600
PM2 | 2024-06-01T10:11:09: PM2 log: ===============================================================================
PM2 | 2024-06-01T10:11:09: PM2 log: [PM2][WORKER] Registering a cron job on: 0
PM2 | 2024-06-01T10:11:09: PM2 log: App [HR-API:1] starting in -fork mode-
PM2 | 2024-06-01T10:11:09: PM2 log: [PM2][WORKER] Registering a cron job on: 2
PM2 | 2024-06-01T10:11:10: PM2 log: App [PlexAPI:3] starting in -fork mode-
PM2 | 2024-06-01T10:11:10: PM2 log: App [HR-API:1] online
PM2 | 2024-06-01T10:11:10: PM2 log: App [TelegramChatBot:4] starting in -fork mode-
PM2 | 2024-06-01T10:11:10: PM2 log: App [PlexAPI:3] online
PM2 | 2024-06-01T10:11:10: PM2 log: App [TelegramChatBot:4] online
Metadata
Metadata
Assignees
Labels
No labels