# start a program at boot, before any other service



## antolap (Dec 17, 2017)

If I want to start a program at boot time, before any service are started, in which file I should put it?

rc.local is started at the end, which is started as first ?


----------



## leebrown66 (Dec 18, 2017)

rcorder(8) is your friend here:


```
rcorder /etc/rc.d/* /usr/local/etc/rc.d/*
```

prints the order the rc scripts will be run in.


----------



## antolap (Dec 18, 2017)

and what should I put in the my custom rc file to ensure that it will be the first in the list of rcorder ?


```
# PROVIDE: xx
# REQUIRE: xx
# KEYWORD: xx
```

only these lines influence boot order?
what to write, to be the first to run?

Tomorrow I'll study manual pages


----------



## Eric A. Borisch (Dec 18, 2017)

See also `service -e` — prints enabled rc scripts in order.

And you’ll likely want something like


# AFTER: FILESYSTEMS
# BEFORE: NETWORKING


----------



## ralphbsz (Dec 18, 2017)

antolap said:


> ... before any service are started, ...


Serious?  Before file systems are mounted, before sysctl is configured, before networking is up?  I doubt it.

It might help if you could explain what you are trying to accomplish.


----------



## antolap (Dec 18, 2017)

Ok solved


----------



## MarcoB (Dec 18, 2017)

How?


----------



## antolap (Dec 18, 2017)

putting:

```
# BEFORE hostid
```

in /etc/rc.d/myfile

I don't know if there's an absolute solution


----------



## leebrown66 (Dec 18, 2017)

Hacking /etc/rc is the only way to be absolutely sure.  Look for _both_ calls to rcorder, after that insert your script in the start of the list.  Then nothing can override your script and your script totally ignores the positioning directives.


----------

