I have a script (PowerCLI) that I trigger from an HA Alarm. This script works just fine and it outputs to a log file as it runs. It is initiated correctly, it connects to vCenter correctly, it parses through events to find the list of VMs affected (which BTW should be a built-in report/function IMO, but I digress).
The script works correctly. However, in certain circumstances, enough VMs were affected or enough events need sorting that what I've noticed is that ~5 minutes from the initation of the script, it dies. In the events, I get the following:
I look at the log file for the script and it is functioning perfectly until about 5 minutes after initiation at which point it simply stops, like something just killed the process tree. There are other Alarm-triggered scripts that I'm planing right now that I *KNOW* will run longer than 5 minutes, but I cannot find the setting that controls this timeout to increase it.
Can anyone help me?
Hi
Welcome to the communities.
Please share your script file & check all service dependency..
As this happens consistently in multiple scripts, that seems a bit irrelevant but ok. The code I'm using to test is as follows:
$initiated = Get-Date
$secsToLoop = 1000
echo "$(date -format s) - Going to loop for $secsToLoop seconds"
$i=1
while ($i -lt $secsToLoop){ echo "$(date -format s) - Sleeping for a sec ($i)"
sleep -s 1
echo "$(date -format s) - Waking up"
echo "-------------" if (($i % 10) -eq 0) { $now = Get-Date $diff = Get-DateDiff -date1 $initiated -date2 $now echo "Has been $diff since initiation"
echo "Now $(($i / $secsToLoop) * 100)% completed"
} $i++
}
And in the log file, I consistently get to:
-------------
2013-02-19T18:48:41 - Sleeping for a sec (280)
2013-02-19T18:48:42 - Waking up
-------------
Has been 00:04:44.0294322 since initiation
Now 28% completed
2013-02-19T18:48:43 - Sleeping for a sec (281)
2013-02-19T18:48:44 - Waking up
-------------
2013-02-19T18:48:44 - Sleeping for a sec (282)
2013-02-19T18:48:45 - Waking up
-------------
2013-02-19T18:48:45 - Sleeping for a sec (283)
2013-02-19T18:48:46 - Waking up
-------------
2013-02-19T18:48:46 - Sleeping for a sec (284)
2013-02-19T18:48:47 - Waking up
-------------
2013-02-19T18:48:47 - Sleeping for a sec (285)
2013-02-19T18:48:48 - Waking up
-------------
2013-02-19T18:48:48 - Sleeping for a sec (286)
2013-02-19T18:48:49 - Waking up
-------------
2013-02-19T18:48:49 - Sleeping for a sec (287)
2013-02-19T18:48:50 - Waking up
-------------
2013-02-19T18:48:50 - Sleeping for a sec (288)
2013-02-19T18:48:51 - Waking up
-------------
2013-02-19T18:48:51 - Sleeping for a sec (289)
2013-02-19T18:48:52 - Waking up
-------------
2013-02-19T18:48:52 - Sleeping for a sec (290)
At which point the script simply ends and vCenter shows an Event with the error mentioned in the OP.