SoFunction
Updated on 2025-03-09

Alternative solution for Serv-U to stop services (batch monitoring and running)

Recently, Serv-U was used to set up an FTP server to bridge files for file transfer. Good times don't last long, and every once in a while, the Serv-U service will automatically stop. Because this ftp service is very important, it is necessary to ensure that it can work normally every day. If you rely solely on people to check whether the service is normal every day, it will not be very reliable. So, Google it. There are various statements on the Internet. For example, when FTP has a large traffic, Serv-U will automatically stop service due to busyness. In short, the reason why Serv-U periodically stops service cannot be found. There is no way, so I have to change my thinking: I can't find the reason why Serv-U periodically stops the service. Then after the Serv-U service is stopped, it can be detected that the service stops automatically starts the Serv-U service. This solution is also unsatisfactory.

Plan: Execution plan + batch processing. Set up the execution plan and execute a batch task every 30 minutes. The role of batch processing: read the process list and check whether the Serv-U process exists; if the process does not exist, start the service and output the log.

Here is the batch implementation part:

Copy the codeThe code is as follows:

@echo off
for /f "usebackq" %%i in (`"tasklist|find /c """`) do (
set chkstat=%%i
)

if %chkstat% == 0 (
net start Serv-U
echo ================ >> %date:~0,10%.log
echo %date% %time% check Serv-U service stop >> %date:~0,10%.log
echo restart Serv-U service! >> %date:~0,10%.log
echo ================ >> %date:~0,10%.log
)


The file names of the versions are different, we can also use this code to monitor other programs. The serv_u6 version needs to be replaced with. You can check it in the tasklist. It must correspond to the exe file name and service name.