Login | |
|
 |
Suggestions - 7/18/2007 8:54:15 AM
|
|
 |
|
| |
DiGiTAL.SkReAM
Posts: 1194
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
|
I have found myself in need of a script being run once every few minutes, on an ongoing basis, for as long as the server is running. Basically, I want to check for the existence of a file, for example, once every 2 or 3 minutes, round the clock. Now, I have all the code put together, and COULD do it with a set of scripts and the task scheduler, but... that just seems really kludgy to me. What I want to ask is... when you guys/gals get into a situation where you need to have some script or command run over and over every few minutes, what do you use? A set of scripts? A third-party app? Thanks, DS
_____________________________
"Would you like to touch my monkey?" - Dieter (Mike Meyers) "It is better to die like a tiger, than to live like a pussy." -Master Wong, from Balls of Fury
|
|
| |
|
|
|
 |
RE: Suggestions - 7/18/2007 9:22:14 AM
|
|
 |
|
| |
DiGiTAL.SkReAM
Posts: 1194
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
|
Ne'ermind, I'm writing a mini-app that will be run as a service and will do this for me. Of course, I am using vb 2005 express, so who knows how "mini" this thing will be. <sigh>
_____________________________
"Would you like to touch my monkey?" - Dieter (Mike Meyers) "It is better to die like a tiger, than to live like a pussy." -Master Wong, from Balls of Fury
|
|
| |
|
|
|
 |
RE: Suggestions - 7/19/2007 1:41:20 AM
|
|
 |
|
| |
DiGiTAL.SkReAM
Posts: 1194
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
|
Thanks. The existance of a file was just an example of a task to perform. I am actually using WMI to monitor the status of the UPS attached to the server. In the event of a On Battery event, if it lasts longer than 2 minutes, I will hibernate all the machines on the network, stop the exchange, blackberry, and SQL services, and hibernate the servers.
_____________________________
"Would you like to touch my monkey?" - Dieter (Mike Meyers) "It is better to die like a tiger, than to live like a pussy." -Master Wong, from Balls of Fury
|
|
| |
|
|
|
 |
RE: Suggestions - 7/19/2007 8:34:40 AM
|
|
 |
|
| |
Fredledingue
Posts: 383
Score: 0
Joined: 5/9/2005
From:
Status: offline
|
Why can't you run the script forever with a 2~3 minutes sleep in a loop?
_____________________________
Fred
|
|
| |
|
|
|
 |
RE: Suggestions - 7/20/2007 4:57:26 AM
|
|
 |
|
| |
DiGiTAL.SkReAM
Posts: 1194
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
|
Because I won't have any way of knowing if the script has crashed or is still working. by starting a new script, I am basically starting with a clean slate and can chekc for status.
_____________________________
"Would you like to touch my monkey?" - Dieter (Mike Meyers) "It is better to die like a tiger, than to live like a pussy." -Master Wong, from Balls of Fury
|
|
| |
|
|
|
 |
RE: Suggestions - 7/20/2007 11:30:48 AM
|
|
 |
|
| |
DiGiTAL.SkReAM
Posts: 1194
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
|
I don't want to see the result. The results would be pretty obvious - the lights in the building are all out, and UPS's are beeping like crazy. lol After much battle with Vb.express.2005.crapola, I decided to kludge it and go with task scheduler. *sigh* Here's the logic flow, as it stands right now. Once a minute, kicks off a script (named appropriately enough, KickOff.vbs) that: 1> Check for power.out file. 1a> If file eixsts, exit. 1b> If file does not exist, continue 2> Check for process named cs_service.exe 2a> if process exists, kill it. 3> Spawn CheckUPS.vbs script using a copy of cscript.exe named cs_service.exe 4> Exit CheckUPS.vbs 1> Check UPS status via WMI 1a> if On A/C power, exit 1b> If on Battery power, continue 2> Create a file named power.out 3> Begin a counter, C1 4> In a Do...Loop, check the UPS staus. 4a> if on A/C power, exit 4b> if still on battery, continue 5> For every second that the UPS is on battery, increment the C1 counter. 6> if C1 = 120, spawn Power_Down.vbs 7. Exit Power_Down.vbs 1> Get a list of workstations currently online on the network 2> Send a hibernate command to each of these. 3> After they are hibernated, stop the exchange and blackberry services on the exchange server 4> hibernate the exchange server 5> Stop the SQl service on the local server 6> Set a flag int he registry that the server hibernated after 2 minutes battery time. 7> hibernate the local server Changes to the above will be: a) Instead of a power.out file, will use a flag in the registry. b) Will Clear the flags upon first run after a hibernate i have 99% of the code written, and tested in sections. I am now trying to find the time to test the whole thing and portablize (is that a word?) the code so that it will run on various networks/servers, and not just mine. Once done, will post int he post yer code section. Thanks for the tips, folks.
_____________________________
"Would you like to touch my monkey?" - Dieter (Mike Meyers) "It is better to die like a tiger, than to live like a pussy." -Master Wong, from Balls of Fury
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|