Kaseya Community

how to run a script only certain days of week

  • I use the script that checks for a successfull backup report with last 24 hours and if not it creates an alert. however it is incorrectly creating alerts for the weekends as none of my customers backup at the weekend. I need to only run the script on tuesday, wedenesday, thursday, friday, saturday. any help in being able to achieve this will be great.

    Legacy Forum Name: how to run a script only certain days of week,
    Legacy Posted By Username: Dean Osborne
  • A couple of ideas to think of... might want to skip directly to #5.

    1) We do this now by using vbscript to create a file with the day in it and then have a script check that file and do an IF CONTAINS on the contents.

    2) This could be improved by running a script and simply creating a file if it's a weekday or deleting the file if it's a weekend. Then execute the next script which checks for the existance of the file.

    3) You might also be able to use Kaseya Views or the PCs registry to see if there is a value that indicates the current day of the week.

    4) You could schedule the script to run on Mondays only and have it reschedule itself to run again in 24 hours. You would need to use a counter so that after 5 runs, it doesn't reschedule itself.

    5) Just tried this, but you might want to monitor it. Have a script that you run on Monday's, by starting it on monday's and run it every 7 days. The sole purpose of that script is to have 5 lines that schedules your targetted script to run at intervales of 0, 1440, 2880, etc. minutes. When you do this, you'll actually see the same machine show up 5 times on the list. One for each day that it is suppose to run.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: doug.jenkins@ispire.ca
  • This has been a feature request submitted to Kaseya already. From my understanding, it will be incorporated in the next release.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: shickey
  • Thanks Doug, option 1 seems most logical. this sounds stupid but I have never used a vbscript could you please let me know how I would achiveve it to create a file

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Dean Osborne
  • Dean Osborne
    Thanks Doug, option 1 seems most logical. this sounds stupid but I have never used a vbscript could you please let me know how I would achiveve it to create a file


    Here's some logic for your VBScript to check and see if the current day is on the weekend or not. This would be saved as a .VBS file and executed using CScript.exe like this: CScript Script.vbs

    You would have to add into the VBScript what you're actually trying to do. You would put the code where it says to execute your code.

    dim dayWeek
    dayWeek = datepart("w",(date))
    If dayWeek
    REM Execute your code here
    WScript.Echo dayWeek
    Else
    REM It is the weekend. Do not do anything.
    End If



    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: RCS-Michael
  • That will be a welcome enhancement to have additional scheduling optionsSmile

    I had the same problem as the author, and opted to create an alarm only if a backup event was missing for more than 72 hours. It's not perfect, just a quick compromise. I also have alerts defined that send emails to client for every successful or failed backup - so the lack of any email on a weekday is a signal to the client that the backup never ran. But we know how clients are, so we really do want to alert them should the backup never launch or terminate...

    In the meantime, I like Doug's #5 approach as it's all done with Kaseya scripting...

    shickey
    This has been a feature request submitted to Kaseya already. From my understanding, it will be incorporated in the next release.


    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: ReedMikel
  • Just search for RunWhen on the forum. I posted it sometime ago.

    Matt

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: connectex
  • Another option (similar to RCS's, except in just a bat form) is:

    @echo off
    for /F %%i in ('date /T') do goto %%i
    goto end

    :Fri
    :Thu
    :Wed
    :Tue
    :Mon
    rem Do Weekday things here
    goto end

    :Sat
    :Sun
    Rem Do Weekend things here


    :end


    Still not part of the scripts, but at least it doesn't rely on anything in particular. It does assume that your end goal is to run some app or script. If you need it to govern a Kaseya script line, it's not your answer.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: rhayes@expertnetsolutions.com