Killing a stalled FTP job in Windows

We’ve been having a scheduled FTP job hang up, and it’s holding up tons of other processes randomly over the last few weeks. Frustrated by how much work it sometimes takes to fix the errors it causes, I made a simple script change to start the job, wait 30 seconds (since it generally takes less than 15 seconds to complete), then kills it if it’s been hung up. It’ll then notify me that it had to be killed. Code follows.

start “ftpjob” ftp -s:ftpscript.txt
@timeout /t 30
REM taskkill /fi “WINDOWTITLE eq ftpjob*” /f
taskkill /fi “WINDOWTITLE eq ftpjob*” 2>NUL | findstr SUCCESS >NUL
@ECHO OFF
set taskerror=%errorlevel%
if %taskerror% == 1 (
echo ftpjob FTP was not running
)
if %taskerror% == 0 (
echo Killed ftpjob FTP. Sending email …
mapisend -u “nope” -p “hahafunny” -r “nottelling” -s “ftpjob ftp killed”
)

Leave a Reply

Your email address will not be published. Required fields are marked *