简体   繁体   English

如何在命令提示符中无限运行批处理文件

[英]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. (我正在使用 pm2)我希望这种情况持续发生并且需要某种循环的帮助。 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?我怎样才能让它工作?

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.这个概念可以使用 GOTO 命令来完成,该命令允许您将 go 定位到脚本中由您在脚本中使用的 a:label 标识的点。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM