Resolution of timer failure caused by IIS process recall (CMD command)

  • 2020-05-13 04:10:46
  • OfStack

The website developed by the company USES.net, and the website USES timer, which is put in the file Global.asax.cs. However, since IIS is set up to periodically recycle the website process, the timer is gone after recycling. If you don't let the process recycle, you worry about memory leaks in the program. Some people say you can make an HTTP request at Application_End, but there is no difference between doing this and setting up not to let the process recycle, and the result is that process 1 runs straight and only if there is no memory leak. Some people say you can use Windows Service, and they don't understand that, so they give it up. Finally, I came up with a way to write a script command (the DOS command in this case) to visit the site, and then execute the script periodically through Windows's task plan. Run the.bat file as shown below, and find that it will open www.baidu.com with the IE browser, and close it after a few seconds.


:: Visit the site and trigger the timer
::ping10 Close after the second time, 10 Second approximate delay 10 Seconds or so, not very precise, and then close IE Browser processes and child processes
 start iexplore.exe  www.baidu.com :: For the sake of confidentiality, there is no photo here to visit the site
 ping -n 10 127.0.0.1>nul
 taskkill /f /im iexplore.exe  /t

Task planning in the attachment - system tools, you can "create the basic task" and "create the task", the former is relatively simple, the shortest interval of the timer is 1 day, the latter is more powerful 1, the shortest interval of the timer is 1 minute. Here I use "create tasks", can be set in the "normal" "only when running in user" or "no matter whether the user login to run", set up here "no matter whether the user login to run" (note: choosing the, all the parameters are set will be required to enter your account password, if the account password is empty, you will be prompted error, but also have an empty password seemingly solution), configuration choice and match that of your computer. Time to establish a good task, when the timer is no open IE browser window, then look at the task manager, have process iexplore exe, and site is indeed being accessed (before the plan task to run, the website process is closed, and no one can guarantee the paragraph time visit, now find the site in the operation of the process), after many set parameters and testing, the result still. But if you set it to "run only when the user logs in", you can see that the timer will open the IE window when it arrives. Then I saw a post on CSDN, in which someone said that if it was set to "run whether the user is logged in or not", the program would run in the background. To see the interactive interface, I would use the DOS command at to add the task plan. It seems to me that this is true, but it's ok to know that the program is running in the background and you can't see the interface. Maybe this is an bug of Windows.

Disadvantages:

, tasks, plan the shortest interval timer for 1 minute, if short again, is powerless, actually even if can, also do not use this method to activate HTTP request site process, set hair once every 5 seconds before HTTP request, the server hang up and can only restart, also didn't found out (on a later request know not because HTTP caused by frequent, as for HTTP request will not lead to crashes frequently, I don't know. According to the event log, it was found that the reason for this crash was that Windows was automatically updated and restarted. The computer started to restart at around 3 o 'clock, but did not get up until 9 o 'clock. After that, I called the customer service of wanwang and they said that the computer was still on the shutdown interface, which seemed to be an automatic update problem. Let them reboot, OK, and disable automatic updates.

2. Closing IE means closing all the pages. If we are using IE to look at other pages at this time, it will also close, but fortunately, because it is on the server, no one will open IE.


Related articles: