• /etc/rc.local: You can add a command or script to the end of the /etc/rc.local file to be run at PC startup.
  • systemd: You can create a systemd service that runs at PC startup. For example, you can create a /etc/systemd/system/my_service.service file with the following content:

[Unit]
Description=MyService
After=network.target
[Service]
ExecStart=/path/to/my_command
Restart=always
[Install]
WantedBy=multi-user.target

example:

ExecStart=/etc/hosts-update.sh

You can then enable and start the service with the following commands:


sudo systemctl enable my_service
sudo systemctl start my_service

On macOS the file to configure is different, but I’m not interested in making a tutorial about that.