Schedule

Anyone know how to make an schedule to run a script every date 11 each month?

I don’t know exactly how, but you can check every day
:if (11 = [:pick begin=8 end=10 [/system/clock/get date as-string]] do={…} else={…}

Please, when you open a topic, give it a relevant title,
otherwise if all the topics on the scheduler were called "Scheduler" you know what a mess.


Schedule something each day, and on sceduler on on-event:

# create a function getday that return the current day set on RouterOS, as number
:global getday do={
    /system clock                                    ; # go to system clock subsection
    :local vdate [get date]                          ; # put the current date into the variable vdate
    :local vdoff [:toarray "0,4,5,7,8,10"]           ; # create one array vdoff with the year, month, and day position on the vdate string
    :if ($vdate ~ ".../../....") do={                ; # if the date is on old format mmm/dd/yyy
        :set vdoff [:toarray "7,11,1,3,4,6"]         ; #     set vdoff with the correct values for old format
    }
    :local dd [:pick $vdate ($vdoff->4) ($vdoff->5)] ; # pick the day from vdate, the starting and ending points are read from vdoff position 4 and 5
    :return [:tonum $dd]                             ; # convert the string 01..31 to a number, and return that value
}

:if ([$getday] = 11)  do={

# call or put the script here

}
1 Like

Fun…

Don’t write things at random or made up from who knows what, and at least try them before writing them on the forum.

What’s wrong with that suggestion? Imo, it’s simple and easy to understand.

:if (26 = [:pick begin=8 end=10 [/system/clock/get date as-string]]) do={ :put "today is the 26th" }

or perpahs

:local day [:pick begin=8 end=10 [/system/clock/get date as-string]]

:if ($day = 26) do={ 
    :put "today is the 26th" 
    # let's do something today..
}

I add a comment to each line, now is more clear…



Is untested and do not work (ignoring the “…” ), and do not work on all v6 / v7.10- / 7.10+ , since the OP do not specify the version.
is less readable and confusing “if the 11 is the day” if (11 = day) versus “if the day is the 11th” if (day = 11)
Also on your script you write $day = 26 and not 26 = $day

Separate question: why “as-string”?
Actually 7.14.3 return “str” regardless is used or not as-string…