Scheduling a batch file every 10 seconds
Recently while investigating high cpu issues in an web application, I wanted to take thread dumps (through jstack) every 10 seconds. First thought was to schedule the batch file through a task scheduler, but I realized that with the task scheduler you cannot set a repetition interval lower then a minute.
An alternative approach would be to use a ping command in the batch file.
:loop jstack <process-id> &:: Add your command here. ping localhost -n 11 > nul goto loop
The ping command will execute for 10 seconds, and all the output will be redirected to the NUL device, meaning that you will see no output from the ping command. It works indeed as a “sleep” command would.
Posted on September 7, 2012, in windows and tagged batch-file, ping. Bookmark the permalink. Leave a comment.
Leave a comment
Comments 0