Jump to content

Script lifecycle AKA script engine tables

Recommended Posts

Another point of clarification from the Great @MartynKeigher:

Scripts life-cycle is.... scheduledscripts >> pendingscripts >> runningscripts >> h_scripts & h_script

One-off scripts are still put in the scheduler. even if it is scheduled for 'now'\'run once'.

We (CW) do NOT write directly into pending scripts. some plugins DO do that.. but that's [not recommended].

Link to post
Share on other sites
3 hours ago, MetaMSP said:

We (CW) do NOT write directly into pending scripts. some plugins DO do that.. but that's [not recommended].

There are of course exceptions to this "rule".

For instance, when you use the Script Run function with a Delay Minutes value > 0.  As an example, if your script runs another script with a delay of 600 minutes, it should not start for 10 hours.  Nothing is written to ScheduledScripts, it doesn't need to be "scheduled".  RunningScripts only contains scripts that have been assigned a ThreadID, whose start time has arrived.  So the delayed script from this function is added to the PendingScripts table, with the start time set for 10 hours from now.  When the start time arrives, the script will be picked up from PendingScripts and added into RunningScripts.

The other exceptions are agent initiated scripts: Tray Scripts, Patching Scripts, BITS Resumed scripts, and Agent OfflineScript Scripts.  But these are all intended to be executed right away.  The Delayed Script Run case is the only example I know of where something is "scheduled" to start later using PendingScripts.

For an external tool (SQL query, plugin, etc.) using ScheduledScripts is best to ensure audit logs are correct, to support location/group/client targets with search limiters, to distribute scripts over a period of time, to support agent timezone compensation, etc.

  • Thanks 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...