Se você estiver executando uma distribuição Linux que usa Systemd ,no meu caso o Debian 12, poderá descobrir que seu comando no arquivo /etc/rc.local não seria executado no momento da inicialização do sistema. Este guia explica como ativar o script /etc/rc.local para ser executado na inicialização do sistema.
Se vc digitar este comando no terminal:
sudo systemctl status rc-local
Você pode obter esta saida no terminal:
rc-local.service - /etc/rc.local Compatibility
Loaded: loaded (/lib/systemd/system/rc-local.service; static)
Drop-In: /usr/lib/systemd/system/rc-local.service.d
└─debian.conf
Active: inactive (dead)
Docs: man:systemd-rc-local-generator(8)
E se você tentar ativar /etc/rc.local para executar na inicialização do sistema com o comando:
sudo systemctl enable rc-local
E obter esta saida no terminal:
The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
Alias= settings in the [Install] section, and DefaultInstance= for template
units). This means they are not meant to be enabled using systemctl.
Possible reasons for having this kind of units are:
• A unit may be statically enabled by being symlinked from another unit's
.wants/ or .requires/ directory.
• A unit's purpose may be to act as a helper for some other unit which has
a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer,
D-Bus, udev, scripted systemctl call, ...).
• In case of template units, the unit is meant to be enabled with some
instance name specified.
Eu Tenho a Solução:
1º Crie o arquivo rc-local.service com o comando abaixo:
sudo nano /etc/systemd/system/rc-local.service
2º Adicione este conteudo ao arquivo /etc/systemd/system/rc-local.service:
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
3º Passo crie o script /etc/rc.local com o comando abaixo:
sudo nano /etc/rc.local
4º Adicione este conteudo ao arquivo /etc/rc.local:
#!/bin/bash
exit 0
5º execute a permissão no arquivo /etc/rc.local:
sudo chmod +x /etc/rc.local
6º Passo habilite o serviço na inicialização do sistema:
sudo systemctl enable rc-local
7º Passo inicie o serviço e check o status do mesmo:
sudo systemctl start rc-local.service
sudo systemctl status rc-local.service
Se tudo correu bem vc terá esta mensagem na saida do terminal: