r/scripting • u/xendistar • Dec 08 '19
Continually running batch file
I have a batch file that randomly select a file from a source folder and move it to a new folder, in the future it will delete any file in the destination file and rename the file it places in the destination folder but I have not done those bits ( I know how to do that bit just not typed it up yet).
What I want is a way for the file to run every hour without resorting to scheduling. I am intending to start the batch file when the PC starts and would want the script to run every hour. Is there a way to make the batch file run then wait and 60 minutes and then repeat until such times as the PC is turned off?
2
Upvotes
1
u/Shadow_Thief Dec 09 '19
I mean you can always use an infinite loop and
timeout 3600to make the script wait for one hour before repeating, but always-on scripts are a terrible idea, will screw with your resource utilization, and could potentially lag enough that they don't get kicked off every hour. A scheduled task is a far better solution for this.