Kaseya Community

Reschedule if offline

  • Hey,

    Has anyone worked out how to reschedule a script if offline?

    I'd like to schedule the nightly maintenance to the next night if the machine is offline. ALSO, if poss, sending a message to the computer saying 'maint did not run, please leave your computer on tonight' would be great.

    Cheers,
    Chris

    Legacy Forum Name: Reschedule if offline,
    Legacy Posted By Username: chris@busy.co.nz
  • Not in front of K right now, but I have a similar script that we set an if statement on that was able to tell us if the machine was available. If the if statement failed, our else was to reschedule the script by x (24?) hours.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: DiPersiaTech
  • Yeah that's basically what I want to do, but I can't work out which if is going to achieve that.

    Any chance you can poke your nose at that script and let me know?

    Cheers.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: chris@busy.co.nz
  • OK, so that's not exactly what we're doing. We're testing if a user is online and basing our run off that.

    I guess what you could do is test to see if a vital service is running - like the workstation service. If it fails, you could tell the script to reschedule itself for x hours.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: DiPersiaTech
  • I haven't tested this but if you do a get variable and utilize the database view there is a field in the vAgentOnline called "online" which is set to 0 or 1 depending if the agent is online.

    If it's 0 (offline) then reschedule it 24 hours later.

    The problem is, that I'm not sure if a script will run at all if an agent is offline or if it will wait until the agent comes back online. I would hope in this case since your not doing anything with the client, it actually will still run.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: doug.jenkins@ispire.ca
  • doug.jenkins@ispire.ca
    I haven't tested this but if you do a get variable and utilize the database view there is a field in the vAgentOnline called "online" which is set to 0 or 1 depending if the agent is online.

    If it's 0 (offline) then reschedule it 24 hours later.

    The problem is, that I'm not sure if a script will run at all if an agent is offline or if it will wait until the agent comes back online. I would hope in this case since your not doing anything with the client, it actually will still run.


    Al script WILL NOT run on an agent that is offline. It will either queue it or skip it depending on how you scheduled it.

    In Christ,
    Marty

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Missing Link
  • Thanks Guys. Take it as a no for now?

    Comes down to that other thread i suppose - is the scripting engine adequate?

    Cheers,
    Chris

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: chris@busy.co.nz
  • It just dawned on me how to do this.

    Run the nightly maintenance with "skip if offline" enabled.

    Set the last step of script to write to the windows event log reporting that the maintenance was completed.

    Schedule another script at 6am or whenever looking for that windows event log. If it exists that's fine. If it doesn't let the user know with a send message and re-schedule the nightly maintenance for that night (in 27 hours or something). ** EDIT - oops - 15 might be better

    This is all quite easy to do I'll whip something up and post it when I get time.

    Regards,
    Chris

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: chris@busy.co.nz
  • Similar to what Chris suggested, but a slighly different twist...

    Assume that you want the script to run daily. Schedule your main script to run at the designated time, say 2AM (call that script #1).

    At the beginning of script #1, delete a file called script1.txt from the Agent Temp folder, skip if failed.

    Near the end of script #1, write the file script1.txt to the Agent Temp folder.

    At the end of script #1, call script #2.

    In script #2, check the date/time of the script1.txt file. If it is later than 4AM (schedule time of 2AM + 2 hours), then the script must not have been run overnight, then display a popup message on the screen. (Will also have to check for user logged-in, in order for the popup to actually display).

    Same logic would apply if the script shoudl run weekly, instead of daily.

    Just an idea...

    Lloyd

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: lwolf
  • We do this yet another way.

    Our maintenance script runs every day with skip if offline set. The If statement checks a registry key for the lack of the word 'Completed' which is only set after the maintenance completes, which means that users can even turn the machine off in the middle of the maintenance and it will start again the next night, and so on until completed.

    Once a month (or whatever the maintance schedule is for that machine) we run a script that sets this flag as 'Scheduled' and another one 5 days later that creates a ticket if maintenance has not completed at which point we force maintenance to occur during the day.

    We also use the same logic with registry keys and reboot scripts so that it is only possible to reboot the machine in predetermined time slots no matter when the script was scheduled. (We accidentally rebooted a couple of servers when we first got Kaseya and so came up with an idiot proof solution pretty quickly afterwards)

    Grant

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: tailormade