Skip to content

SecondsLeft()

ts
function SecondsLeft(): number;

Returns the number of seconds left in the execution loop for the current script. The returned value is a floating-point number, indicating both whole seconds and fractions of a second remaining before the script will be forcibly terminated.

NOTE

Syncplify Server! enforces a maximum execution time for scripts to prevent runaway or excessively long-running processes. Use SecondsLeft() to check how much time your script has left to complete its work.

Example

ts
{
  var sleft = SecondsLeft();
  Log("Seconds left to execute: " + sleft);
  if (sleft < 5.0) {
    Log("Warning: Script is about to time out!");
    // Perform cleanup or exit early if needed
  }
}

TIP

Always check the remaining time in long-running or complex scripts to avoid unexpected termination and ensure proper cleanup.