This little batch file came about from needing to run a cron job from within XAMPP. Since it’s Windows I could have used a scheduled task, but I don’t have XAMPP running all the time and I wanted a little more control over when it runs.
And on this specific project, I’m working on a Moodle plugin that needs to run under cron every minute. So the program that’s running is PHP calling the Moodle CLI cron.php file. You’re probably going to want to change the script that’s called.
:loop php /path/to/your/script.php @timeout /t 60 @goto loop
You’ll want to change the 2nd line to whatever you want to run. Add as many lines as you want. And then change the 60 on the 3rd line to however many seconds you want it to wait. I needed it to run every minute so I’m using 60 seconds.
Now when I need to have cron active I just drop to the command line and run this batch file and leave it running until I’m done.
And for those that haven’t dealt with the command line in a while, or ever, pressing Ctrl-C will terminate the batch file.