Community discussions

MikroTik App
 
antani
just joined
Topic Author
Posts: 7
Joined: Thu Apr 08, 2010 9:45 am

Routeros, operating system services boot order

Thu Jun 08, 2023 9:52 am

Hello everyone,

I can't find any information about the startup order of services when booting RouterOS into a router. I'd like to understand which services are activated first and which ones last, for example, assuming the services are enabled, does the client PPPoE service start before or after the SNTP service? The dhcp server?
Thanks in advance for any hint of clarification.
max
 
holvoetn
Forum Guru
Forum Guru
Posts: 5404
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: Routeros, operating system services boot order

Thu Jun 08, 2023 10:34 am

Check log files, I would think ?
 
pe1chl
Forum Guru
Forum Guru
Posts: 10195
Joined: Mon Jun 08, 2015 12:09 pm

Re: Routeros, operating system services boot order

Thu Jun 08, 2023 11:08 am

I can't find any information about the startup order of services when booting RouterOS into a router. I'd like to understand which services are activated first and which ones last, for example, assuming the services are enabled, does the client PPPoE service start before or after the SNTP service? The dhcp server?
Thanks in advance for any hint of clarification.
max
Why would that matter?
I think it is as usual in today's Linux systems: everything is started in parallel, and it is one big race to see which ones start first and which ones later.
That is often inconvenient when you have older software that relies on certain conditions to exist before it starts, but hey that has been labeled "deprecated" so you have to create a solution.

Indeed it can be observed that some services start before time is set correctly on a MikroTik router. But that cannot really be avoided because setting time requires a working network, and a working network (where time services can be accessed) can depend on just about anything else.
So you will have to live with incorrect time at startup followed by a "time jump" when everything is up.
 
antani
just joined
Topic Author
Posts: 7
Joined: Thu Apr 08, 2010 9:45 am

Re: Routeros, operating system services boot order

Thu Jun 08, 2023 4:09 pm

I was just curious about the execution order of the services because sometimes I found myself scheduling scripts when a router restarted and they didn't execute.
For example, I had scheduled the sending of a notification email when my router restarted, but it was never sent due to the simple fact that the DNS became operational after about twenty seconds.

That's all, thanks for your answers.
 
optio
Long time Member
Long time Member
Posts: 655
Joined: Mon Dec 26, 2022 2:57 pm

Re: Routeros, operating system services boot order

Thu Jun 08, 2023 4:39 pm

For example, I had scheduled the sending of a notification email when my router restarted, but it was never sent due to the simple fact that the DNS became operational after about twenty seconds.
This depends on device speed, startup scheduler with 0 interval triggers 3s after console service runs which can be before other services especially on slow devices. Add delay in scheduler script before other logic or add loop that checks needed service, interfecte, etc... For your example you can add in loop resolve check until successful with some timeout to avoid infinite loop if something is wrong with DNS or internet connection on startup.
 
User avatar
k6ccc
Forum Guru
Forum Guru
Posts: 1490
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)
Contact:

Re: Routeros, operating system services boot order

Thu Jun 08, 2023 5:29 pm

For example, I had scheduled the sending of a notification email when my router restarted, but it was never sent...
I also have a startup script that sends me E-Mail notifications. The scheduler starts the script at start-time=startup. The script writes a log entry and then has a delay 00:00:20 before it tries to send the E-Mail.
Works perfectly.
 
pe1chl
Forum Guru
Forum Guru
Posts: 10195
Joined: Mon Jun 08, 2015 12:09 pm

Re: Routeros, operating system services boot order  [SOLVED]

Thu Jun 08, 2023 5:33 pm

Yes, that is unfortunately the only viable workaround.
Ok, maybe you could make a clever script that does a DNS lookup in a loop (with a delay in the loop) until the resolve succeeds.

When using a fixed wait time the actual delay required depends a lot on the configuration and many external factors.
Some may require 20 seconds, others may require several minutes.
(e.g. when a DSL modem has to train before the internet connection is available)
 
User avatar
k6ccc
Forum Guru
Forum Guru
Posts: 1490
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)
Contact:

Re: Routeros, operating system services boot order

Thu Jun 08, 2023 5:39 pm

As I recall, when I set that up years ago, I tried a couple of delay times, and once I found what worked, I doubled that for the permanent script.
 
antani
just joined
Topic Author
Posts: 7
Joined: Thu Apr 08, 2010 9:45 am

Re: Routeros, operating system services boot order

Thu Jun 08, 2023 5:46 pm

Thanks, in fact after analyzing the system logs I too adopted this solution :)
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Routeros, operating system services boot order

Thu Jun 08, 2023 5:49 pm

I was just curious about the execution order of the services because sometimes I found myself scheduling scripts when a router restarted and they didn't execute.
For example, I had scheduled the sending of a notification email when my router restarted, but it was never sent due to the simple fact that the DNS became operational after about twenty seconds.

That's all, thanks for your answers.
simply add :delay 20s on top of the scheduler before call the script.....
or the right amount of time for your router to go online from poweron.
 
User avatar
k6ccc
Forum Guru
Forum Guru
Posts: 1490
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)
Contact:

Re: Routeros, operating system services boot order

Thu Jun 08, 2023 5:58 pm

From the Wiki for scheduler: startup - execute the script 3 seconds after the system startup.
There is no option in the scheduler to add a different delay for a schedule based on startup.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Routeros, operating system services boot order

Thu Jun 08, 2023 5:58 pm

From the Wiki for scheduler: startup - execute the script 3 seconds after the system startup.
There is no option in the scheduler to add a different delay for a schedule based on startup.
Just wroted.....
:delay 20s (for example)
 
User avatar
k6ccc
Forum Guru
Forum Guru
Posts: 1490
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)
Contact:

Re: Routeros, operating system services boot order

Thu Jun 08, 2023 6:08 pm

From the Wiki for scheduler: startup - execute the script 3 seconds after the system startup.
There is no option in the scheduler to add a different delay for a schedule based on startup.
Just wroted.....
:delay 20s (for example)
That's what I get for believing the manual. Neither the old nor the new Wiki gives any indication of using a delay command In the scheduler...
Delay in the script works fine.
Last edited by k6ccc on Thu Jun 08, 2023 6:16 pm, edited 1 time in total.
 
optio
Long time Member
Long time Member
Posts: 655
Joined: Mon Dec 26, 2022 2:57 pm

Re: Routeros, operating system services boot order

Thu Jun 08, 2023 6:14 pm

From the Wiki for scheduler: startup - execute the script 3 seconds after the system startup.
Either I'm muted and/or writing too cognitive complex text. :)
 
pe1chl
Forum Guru
Forum Guru
Posts: 10195
Joined: Mon Jun 08, 2015 12:09 pm

Re: Routeros, operating system services boot order

Thu Jun 08, 2023 7:25 pm

As I recall, when I set that up years ago, I tried a couple of delay times, and once I found what worked, I doubled that for the permanent script.
Sure, but that holds only for your situation and possibly your test case.
I can guarantee you that on a VDSL line, after a power loss, you will not have internet within 20 seconds.
But when the test case (or the requirement) involves only a reboot (e.g. upgrade) it will be fine.

Who is online

Users browsing this forum: norepto, svh79 and 81 guests