Killing a stalled FTP job in Windows

Steven Brady March 6, 2014
0 people like this post

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”
)

Tags:
Category: Geekery
  • 0
  • 66
Steven Brady

Steven is an intermediate Linux admin, aspiring Internet marketer, husband, uncle, Christian, and a fan of Linux, Android, and the Green Lantern.

Leave your comment