Make PM2 run job only once every 10 minutes
Asked Answered
H

1

13

I have the following .json configuration for a job that I need to run once every 10 minutes and then do nothing for the remaining time...

"name"        : "test.10minjob",
"cron_restart": "*/10 * * * *",
"autorestart" : false,
"exec_mode"   : "cluster",
"instances"   : 1,

If I run it like this, it will run once and never restart.

If I run it with autorestart set to true, it will restart every time the job exits (i.e. is done).

Am I missing something obvious here?

Hare answered 29/7, 2015 at 12:9 Comment(5)
Is "exec_mode" should not be the "cluster_mode" or "fork_mode"?Ticket
this seems correct according to the docs (github.com/Unitech/PM2/blob/master/…). and for cron to work it has to be in cluster mode.Hare
Best would be to use the real cron and setting exec_mode to fork. I can't find how cron is used in pm2 code.Inverness
autorestart should be true possiblyAtor
So your job once it finishes, doesn't exit automatically?Lab
P
2

You could try this cron expression 0 0/10 * 1/1 * ? * I created it using this tool:

http://www.cronmaker.com

The expression looks very different from yours and also if i put yours into a cron parser it complains about an invalid expression.

Pointing answered 15/7, 2019 at 23:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.