Junior — Middle
How can you automate the application startup at system boot in Linux?
sobes.tech AI
Answer from AI
In Linux, there are several ways to automate the startup of an application during system boot:
- systemd service — create a unit file in
/etc/systemd/system/describing the service and enable its autostart:
# Create a file /etc/systemd/system/myapp.service
[Unit]
Description=My Application
[Service]
ExecStart=/path/to/application
[Install]
WantedBy=multi-user.target
Then execute:
sudo systemctl enable myapp.service
-
init.d scripts — for systems with SysVinit, add a script to
/etc/init.d/and set up symbolic links in runlevel directories. -
crontab with @reboot — add a line to crontab:
@reboot /path/to/application
- Add a call in user startup files — for example, in
~/.bashrcor~/.profile, but this runs at user login, not at system boot.
The most modern and recommended method is to use systemd services.