Run TUFLOW From a Batch-file: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 185:
)
</pre>
 
===Shutdown on Completion===
Often we may have a number of TUFLOW simulations going when we leave work on a Friday afternoon, if these are not going to take all weekend to run, using some of the batch file logic above you can create a batch file that will shutdown the computer when no TUFLOW simulations are running. An example batch file for this purpose is below:<br>
<pre>
echo off
 
:do_while_loop_start
set /a count=0
for /f %%x in ('tasklist ^| find /c "TUFLOW"') do set count=%%x
IF %count%==0 (
shutdown.exe /s /t 30
) ELSE (
timeout 60
goto do_while_loop_start
)
pause
</pre>
This batch file counts the number of processes with "TUFLOW" in the process name and if this is greater than 0, a delay of 60 seconds is created and the loop started again. If no "TUFLOW" simulations are running a shutdown command is issued.<br>
To test the batch file it is recommended that you add an "echo" in front of the <tt>shutdown.exe /s /t 30</tt> command to ensure it is working correctly (I use this on a Windows 7 machine, but have not tested it on either XP or Windows 8).<br>
In order to restart the machine rather than power it off the /s can be replaced with /r. This can be useful when a heavily utilised modelling computer needs a restart!