Page 1 of 1

Autoexec

Posted: Wed Dec 15, 2004 4:10 pm
by dusan
Hi all,

is it possible (I didn't find) to run script after the system boot's up? I'm running RouterOS with watchdog and I want to know when the system reboots due to failure.

Posted: Wed Dec 15, 2004 4:27 pm
by edzix
sure, try the following:
/system script add name=bootup source={
   :local upt; :set upt [/system resource get uptime]
   :local runc; :set runc [/system scheduler get run run-count]
   :if (($upt<61s)&&($runc<=1)) do={
        /tool send to=name@domain.com subject="Router has rebooted!"
    }
}

/system scheduler add name=run interval=1m on-event=bootup disabled=no
I think in v2.9 there will be such a setting that will let you to accomplish this in easier way.

Edgars

Posted: Wed Dec 15, 2004 5:14 pm
by dusan
Thanks for fast answer. I hope there will be easier way.

I have another idea, using netwatch watching router's IP address. It will trigger the "up" action after startup but never fail :-). I just wanted know, if does exist eaiser way... Thanks...

Re: Autoexec

Posted: Wed Sep 01, 2021 9:05 pm
by rextended
now RouterOS support event "startup", use the scheduler like:
/system scheduler
add name=on-startup policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-time=startup \
    on-event=":delay 60s;# after initial delay for give time to start all services, insert what you want do here" 

Re: Autoexec

Posted: Wed Sep 01, 2021 9:19 pm
by Jotne
Wow, you are digging deep and find some very a threads: 2004 :)

Re: Autoexec

Posted: Wed Sep 01, 2021 9:23 pm
by rextended
If somone search.. find :)