LL M
LL M

Reputation: 1

How to infinitely run a batch file in Command Prompt

I want to create a batch file that starts a script in a directory, and then restarts that script every hour. (I am using pm2) I want this to happening continuously and need the help of some kind of loop. How will I get this to work?

REM cd to directory here
pm2 start script.js
timeout /T 3600
pm2 restart script.js

This is how my code looks right now. How can I get this to work?

Upvotes: 0

Views: 410

Answers (1)

Squashman
Squashman

Reputation: 14290

This concept can be accomplished using the GOTO command which allows you to go to a point in the script identified by a :label you use in the script.

pm2 start script.js
:LOOP
timeout /T 3600
pm2 restart script.js
GOTO LOOP

Upvotes: 1

Related Questions