Skip to content

Autostart Configuration ​

This article describes how to configure an application to start automatically at boot on the Rhino Pi IQ9N Ubuntu system.

Method Comparison ​

MethodUse CaseCharacteristics
systemd serviceBackground services, long-running programsSupports automatic restart and log management; the recommended approach
crontabSimple scriptsSimple to configure, but not suitable for long-running services
rc.localOne-shot startup scriptsMust be created manually and given executable permissions
  1. Create the service file:
bash
sudo nano /etc/systemd/system/myapp.service
  1. Write the following content:
ini
[Unit]
Description=My Application
After=network.target

[Service]
Type=simple
User=aidlux
WorkingDirectory=/home/aidlux/myapp
ExecStart=/home/aidlux/myapp/run.sh
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
  1. Reload the configuration and enable the service:
bash
sudo systemctl daemon-reload
sudo systemctl enable myapp.service
sudo systemctl start myapp.service
  1. Check the service status and logs:
bash
sudo systemctl status myapp.service
journalctl -u myapp.service -f

Using crontab ​

The cron service is enabled by default on the IQ9N. Edit the current user's scheduled tasks:

bash
crontab -e

Add a task to the file, for example to run a script once at boot:

text
@reboot /home/aidlux/myapp/run.sh

View the currently configured tasks:

bash
crontab -l

crontab is suitable for running simple scripts or scheduled tasks; long-running services should still use the systemd approach.

Using rc.local ​

The system already includes rc-local.service. This service is of type static, so systemctl enable is neither needed nor possible; when /etc/rc.local exists and has executable permissions, systemd runs it automatically at boot.

  1. Create /etc/rc.local:
bash
sudo nano /etc/rc.local
  1. Write the following content:
bash
#!/bin/sh
/home/aidlux/myapp/run.sh &
exit 0
  1. Give it executable permissions:
bash
sudo chmod +x /etc/rc.local
  1. Reboot for the configuration to take effect. You can also verify without rebooting:
bash
sudo systemctl start rc-local
sudo systemctl status rc-local

FAQ ​

  • The service did not start: use journalctl -u <service name> to check the failure reason.
  • The script has no executable permission: run chmod +x <script path>.
  • Wrong path: ExecStart must use an absolute path.
  • rc.local does not take effect: confirm that /etc/rc.local exists and has executable permissions (ls -l /etc/rc.local), then reboot the system after granting permissions.