Jump to content

Script timeout


Recommended Posts

Hello,

My collegue and I have some scripts that are run frequently (possibly during all times, for example at night). Is there a possibility to terminate a script when are certain time elapsed. I thought about some kind of wrapper for the script, but maybe there is a way of doing it inside the script.

Thanks for your help,

Benni and Nico

Link to comment
Share on other sites

Hello,

My collegue and I have some scripts that are run frequently (possibly during all times, for example at night). Is there a possibility to terminate a script when are certain time elapsed. I thought about some kind of wrapper for the script, but maybe there is a way of doing it inside the script.

Thanks for your help,

Benni and Nico

Put

$a=timerinit()

at the start of your code.

Then, in your loop, but something like

if timerdiff($a)>1000 then exitloop

timerdiff($a) equals the amount of milliseconds since $a=timerinit() was run.

Link to comment
Share on other sites

Put

$a=timerinit()

at the start of your code.

Then, in your loop, but something like

if timerdiff($a)>1000 then exitloop

timerdiff($a) equals the amount of milliseconds since $a=timerinit() was run.

We thougt about this. However, It might be possible that our script is waiting for a window that does not exist. There is not always a loop in our script. Right now, we have some kind of wrapper:

run("script.exe")
sleep($delay)
$PID = ProcessExists("script.exe") 
If $PID Then
    ProcessClose($PID)
EndIf
Edited by Rogge_RZN_FHDW
Link to comment
Share on other sites

You could try using winwait to check for the window and you can set a timeout on it so it won't hang.

OR you could make the if timerdiff statement into an adlib, and have it exit the script instead of exitloop.

WinWait("Untitled", "", 5)
Makes the winwait timeout after 5 seconds
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...