Community discussions

MikroTik App
 
dusan
just joined
Topic Author
Posts: 20
Joined: Wed Oct 27, 2004 11:35 am
Location: Czech Republic, Breclav

Autoexec

Wed Dec 15, 2004 4:10 pm

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.
 
edzix
Member
Member
Posts: 333
Joined: Thu Jul 01, 2004 3:01 pm
Location: Latvia

Wed Dec 15, 2004 4:27 pm

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
 
dusan
just joined
Topic Author
Posts: 20
Joined: Wed Oct 27, 2004 11:35 am
Location: Czech Republic, Breclav

Wed Dec 15, 2004 5:14 pm

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...
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Autoexec

Wed Sep 01, 2021 9:05 pm

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" 
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Autoexec

Wed Sep 01, 2021 9:19 pm

Wow, you are digging deep and find some very a threads: 2004 :)
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Autoexec

Wed Sep 01, 2021 9:23 pm

If somone search.. find :)

Who is online

Users browsing this forum: No registered users and 20 guests