Windows under Bat Batch implementation daemon

Source: Internet
Author: User

This article is transferred from the network, because cannot find the original author, therefore cannot know the source. If you are lucky enough to have the original author see, please contact me plus. First reproduced here.

In recent days, overtime and crazy lost, every night can not sleep. Development Department of a core program will always be down, and then need to go manually, and the security level of this service is very high, only I can operate, make my night old can't sleep, last night really can't stand, think of the shell daemon process previously written under HP-UX, This back to a Windows bat version of the daemon, then the evening thought is very slow, called a brother let him write, go up after the effect is good, at least last night I sleep 7 hours.

Early to change the program to improve a number of functions, such as recording.
Realize:
Check if there is a notepad, if you want to use it as your own process name, if the process is down, it will automatically restart (will generate a start.bat in the current directory)

@echo offSet_task=notepad.EXESet_svr=c:\windows\notepad.EXESet_des=Start.Bat: Checkstart for/F "tokens=5"%%n in (' Qprocess.exe ^|Find"%_task%") Do(if%%n==%_task% (GotoCHECKAG)Else GotoStartsvr): StartsvrEcho% Time% Echo******** program starts to start ********EchoProgram restarts at% Time%, please check system log >> Restart_service.txtEcho Start%_svr% >%_des%Echo Exit>>%_des%Start%_des%Set/p=.<nul for/L%%i in (1 1 10) Do Set/P a=.<nul&ping.exe/n 2 127.0.0.1>nulEcho.EchoWscript.Sleep wscript.arguments (0) >%tmp%\delay.VBS cscriptb//nologo%tmp%\delay.vbs 10000del%_des%/QEcho******** program start complete ********GotoCheckstart: CheckagEcho% Time% Program is running normally, check again after 10 seconds.EchoWscript.Sleep wscript.arguments (0) >%tmp%\delay.VBS cscriptb//nologo%tmp%\delay.vbs 10000GotoCheckstart

Windows under Bat Batch implementation daemon

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.