wscript.sleep uses 100% CPU
Author |
Message |
Paco #1 / 8
|
 wscript.sleep uses 100% CPU
I have many .vbs files running as scheduled tasks in a W2000 server SP2. Every vbs file has to execute a few times a .exe file (wscript.run inside a loop), and waits for five seconds (wscript.sleep 5000) before continuing. This has worked very good for months, with the CPU going up (executing the exe) and down (sleeping for a few seconds). Recently, maybe a week ago, I noticed that the computer stopped running scheduled tasks. It had hundreds of wscript.exe processes, I restarted the machine and monitored it for the next days, and I saw that the CPU was always up (wscript.exe 100%) executing the exe file or sleeping, and some wscript.exe processes never end (no error messages). I made a test vbs file that only sleeps, and it also uses 100% CPU. What could have happened to this machine? Is a problem with wscript.exe or with task scheduler? Thanks in advance, best regards
|
Sat, 18 Sep 2004 23:00:15 GMT |
|
 |
Alex K. Angelopoulo #2 / 8
|
 wscript.sleep uses 100% CPU
It sounds like a problem with the scripts. They never terminate. Could you post one? Could you also post your sleep script example that takes 100% of the CPU time? Quote:
> I have many .vbs files running as scheduled tasks in a W2000 server SP2. > Every vbs file has to execute a few times a .exe file (wscript.run inside a > loop), and waits for five seconds (wscript.sleep 5000) before continuing. > This has worked very good for months, with the CPU going up (executing the > exe) and down (sleeping for a few seconds). > Recently, maybe a week ago, I noticed that the computer stopped running > scheduled tasks. It had hundreds of wscript.exe processes, I restarted the > machine and monitored it for the next days, and I saw that the CPU was > always up (wscript.exe 100%) executing the exe file or sleeping, and some > wscript.exe processes never end (no error messages). > I made a test vbs file that only sleeps, and it also uses 100% CPU. > What could have happened to this machine? Is a problem with wscript.exe or > with task scheduler? > Thanks in advance, best regards
|
Sat, 18 Sep 2004 23:01:44 GMT |
|
 |
Paco #3 / 8
|
 wscript.sleep uses 100% CPU
Here is an example code: every10minutes.vbs ... initialize variables, load XML object ... For Each objItem in objRootXML.childNodes ... create text file with xml content ... Set WshShell1 = CreateObject("WScript.Shell") WshShell1.Run (strProgram) <--- Async. call, it takes about two seconds wscript.sleep 5000 <--- 100% CPU for 5 seconds Next <--- No more code here This script, usually moved CPU to 100% (during the EXE call) and then back to 2% the rest of the time of that 5 seconds wait (it had aprox. 3 seconds of 2% CPU). Now, the CPU is always at 100% until the program finishes, and when scheduled (every 10 minutes) aprox. once of every three times, I see a wscript.exe process that never ends consuming 100% CPU, or 2 wscript processes each with 50% CPU, or three processes, 4, 5... or hundreds. If I run the script manually, it always ends OK. I use the same user for scheduled tasks and console. This never happened before (the scripts have been running for more than 12 months), and I don't known what is happening. My test script was as simple as this: msgbox "Start" wscript.sleep 8000 <--- 100% CPU msgbox "End" Tested on other servers, the CPU is always very low with this test. Maybe the wscript.exe is corrupted and I need to reinstall a newer one? Thanks
|
Sun, 19 Sep 2004 00:36:09 GMT |
|
 |
Gordon Bel #4 / 8
|
 wscript.sleep uses 100% CPU
Hi Paco, Try running the program synchronously, rather than asynchronously. WshShell1.Run (strProgram),,1 Does that help? Gordon Bell
Here is an example code: every10minutes.vbs ... initialize variables, load XML object ... For Each objItem in objRootXML.childNodes ... create text file with xml content ... Set WshShell1 = CreateObject("WScript.Shell") WshShell1.Run (strProgram) <--- Async. call, it takes about two seconds wscript.sleep 5000 <--- 100% CPU for 5 seconds Next <--- No more code here This script, usually moved CPU to 100% (during the EXE call) and then back to 2% the rest of the time of that 5 seconds wait (it had aprox. 3 seconds of 2% CPU). Now, the CPU is always at 100% until the program finishes, and when scheduled (every 10 minutes) aprox. once of every three times, I see a wscript.exe process that never ends consuming 100% CPU, or 2 wscript processes each with 50% CPU, or three processes, 4, 5... or hundreds. If I run the script manually, it always ends OK. I use the same user for scheduled tasks and console. This never happened before (the scripts have been running for more than 12 months), and I don't known what is happening. My test script was as simple as this: msgbox "Start" wscript.sleep 8000 <--- 100% CPU msgbox "End" Tested on other servers, the CPU is always very low with this test. Maybe the wscript.exe is corrupted and I need to reinstall a newer one? Thanks
|
Sun, 19 Sep 2004 03:18:24 GMT |
|
 |
Alex K. Angelopoulo #5 / 8
|
 wscript.sleep uses 100% CPU
You're right, that is strange - and I don't know the cause off the top of my head. Two things I would suggest for script execution that can at least "Band-Aid" the problem and may give us more information. ( I think Gordon's suggestion is a good one to try also if your next steps are not time-critical). (1) Try "forcing" batch execution mode if you aren't already doing so by using the //B flag - e.g., cscript //B thescript.vbs (2) Also specify a timeout for the script. Since you re-run it every 10 minutes, you probably want to use a //T:600 or less switch. You might indeed want to try reinstalling WSH; if you have not updated XML, IE, or WSH recently then there is nothing I can see to make the error suddenly appear other than a problem with the files that it uses. Quote:
> Here is an example code: > every10minutes.vbs > ... initialize variables, load XML object ... > For Each objItem in objRootXML.childNodes > ... create text file with xml content ... > Set WshShell1 = CreateObject("WScript.Shell") > WshShell1.Run (strProgram) <--- Async. call, it takes about two > seconds > wscript.sleep 5000 <--- 100% CPU for 5 seconds > Next > <--- No more code here > This script, usually moved CPU to 100% (during the EXE call) and then back > to 2% the rest of the time of that 5 seconds wait (it had aprox. 3 seconds > of 2% CPU). > Now, the CPU is always at 100% until the program finishes, and when > scheduled (every 10 minutes) aprox. once of every three times, I see a > wscript.exe process that never ends consuming 100% CPU, or 2 wscript > processes each with 50% CPU, or three processes, 4, 5... or hundreds. If I > run the script manually, it always ends OK. I use the same user for > scheduled tasks and console. > This never happened before (the scripts have been running for more than 12 > months), and I don't known what is happening. > My test script was as simple as this: > msgbox "Start" > wscript.sleep 8000 <--- 100% CPU > msgbox "End" > Tested on other servers, the CPU is always very low with this test. > Maybe the wscript.exe is corrupted and I need to reinstall a newer one? > Thanks
|
Sun, 19 Sep 2004 03:48:07 GMT |
|
 |
Paco #6 / 8
|
 wscript.sleep uses 100% CPU
Thank you Gordon. Thank you Alex. Running synchronously didn't help I have installed WSH 5.6 (I had 5.1) and sleep works fine on every script except one, maybe wscript.exe was corrupted somehow. There is only one script that still consumes 100% cpu, but seems another issue. Best regards
|
Sun, 19 Sep 2004 22:17:58 GMT |
|
 |
spank #7 / 8
|
 wscript.sleep uses 100% CPU
rather than having the script sleep, can you schedule the task instead?
Quote: > Thank you Gordon. > Thank you Alex. > Running synchronously didn't help > I have installed WSH 5.6 (I had 5.1) and sleep works fine on every script > except one, maybe wscript.exe was corrupted somehow. > There is only one script that still consumes 100% cpu, but seems another > issue. > Best regards
|
Thu, 23 Sep 2004 07:35:21 GMT |
|
 |
Alex K. Angelopoulo #8 / 8
|
 wscript.sleep uses 100% CPU
Actually, he is scheduling them - the problem is he has to do a wait of 5 seconds within the script - and the minimal resolution you get from the Task Scheduler on Win2K is 1 minute, so he can't exactly re-write and schedule everything. Quote:
> rather than having the script sleep, can you schedule the task instead?
> > Thank you Gordon. > > Thank you Alex. > > Running synchronously didn't help > > I have installed WSH 5.6 (I had 5.1) and sleep works fine on every script > > except one, maybe wscript.exe was corrupted somehow. > > There is only one script that still consumes 100% cpu, but seems another > > issue. > > Best regards
|
Thu, 23 Sep 2004 11:23:03 GMT |
|
|
|