Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make PM2 run job only once every 10 minutes

Tags:

node.js

pm2

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?

like image 954
AyKarsi Avatar asked Jul 29 '15 12:07

AyKarsi


People also ask

Does PM2 auto restart on file change?

js App in Development Mode with PM2. At this point, your server will auto-restart each time you create, modify or delete a source file in your project. It also works when you add or remove a dependency with npm or yarn .

How do I run multiple PM2?

Running Multiple PM2 If you want to run multiple PM2 under the same user, you can override the variable PM2_HOME . Setting the PM2_HOME will change the PM2 configuration folder, like communication sockets ( $HOME/. pm2/pub. sock and $HOME/.

What is CWD in PM2?

Process name in the process list. string. Script filename without the extension (app for app.js) cwd. Current working directory to start the process with.


1 Answers

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.

like image 71
arnonuem Avatar answered Oct 31 '22 06:10

arnonuem