JOBS section of the script list

I have this script where all the “GLOBAL VARIABLES” are already declared in other scripts, therefore I consider that I should not declare it again, which I do not understand because the script is executed only once or twice and it no longer appears in the JOBS section, what would be wrong? Thanks for teaching.


:delay 15m

:global stopRouterRun 
:global now
     :local filenameIP "iphistory.txt"

:do {

    /file
    :if ([:len [find where name="flash" and type="disk"]] = 1) do={:set filenameIP "flash/$filenameIP"}
    :if ([:len [find where name=$filenameIP]] = 0) do={print file="$filenameIP"; :delay 5s; set $filenameIP contents=""}
:global currentIP
    :local newIP [/ip address get [find interface="ETHERT 1"] address]
    :set newIP [:pick $newIP 0 [:find $newIP "/" -1]]
    :if ($newIP != $currentIP) do={
    /file
    :delay 5s
    :local filecontent [get $filenameIP contents]
    :local newfilecontent "********************************************************************\r\nNEW IP:     $newIP\t$now\r\n$filecontent"    
    set $filenameIP contents=$newfilecontent
    :set currentIP $newIP
}

    :delay 10s
} while=(!$stopRouterRun)

EL DONCITO.

Is not exactly like the original…
http://forum.mikrotik.com/t/help-with-this-script/157065/14

What problem you have to leave it as is, and on other script use other variable names?
The only global variable used on original script is storedIP for compare previous IP with the actual, all other can be perfectly local only…

Also scheduler exist, is not needed to make for each script a permanent job on loop…
Scheduler is invented exactly to run scripts on intervals…

Also if the job on loop is interrupted, for example because the address is missing on that moment, or interface is not ready, you must manually restart…
Instead with scheduler, every x time the run of the script is retried, an probably work near everytime.

Ok rextendex, but doesn’t that make the routerboard have more consumption in the CPU or memory?



EL DONCITO.

Approx “9+8+32 Bytes” ?

Consume more precious CPU resources various processes in loops…

Just “invented” this for test the memory occupied from 10.000 global variables
[rex@net] /system resource> :put [get free-memory]
213348352
[rex@net] /system resource> :for x from=1 to=10000 step=1 do={ [:parse “:global abcdefgh$x 255.255.255.255/32”] }
[rex@net] /system resource> :put [get free-memory]
212856832
[rex@net] /system resource>
10.000 variables with name from 9 characters to 13 (abcdefgh1, abcdefgh2… abcdefgh9999, abcdefgh10000) and “fake” IP-prefix as internal value
use 491520 Bytes, near 50 Bytes for each variable…
and I deduce than a device with 256.0MiB can store 4.000.000 of global variables before start to be a problem…

I did what you told me friend REXTENDED, and it didn’t work, when the IP changes 2 times, the script stops working, is that because?
Because what I want to do is that every time the routerboard is restarted, the script starts, it takes 15 min, after those 15 min the script is executed and it is running every 10 seconds.





EL DONCITO.