Raspberry Pi 2 Model B working with auto startup

Free Internet troubleshooting agent for ARM based devices. Raspberry 3A, 3B+ and others. Outages.io finds connectivity issues, gives you hard facts.

Moderator: peachy

Post Reply
OutagesUser2021
Posts: 5
Joined: Thu May 06, 2021 2:26 pm

Raspberry Pi 2 Model B working with auto startup

Post by OutagesUser2021 »

I managed to get the agent working on a Raspberry Pi 2 Model B, and also got it to run automatically on startup after trying a bunch of things. Here are the details:

Clean install of Raspberry Pi with Desktop from the official Raspberry Pi web site: https://www.raspberrypi.org/software/
I used the Raspberry Pi imager on Ubuntu 16.04 with a 16 GB microSD card

Downloaded the agent and created the agentid file per instructions
Moved the agentid file to /etc
Moved the agent binary to /usr/sbin
Set executable permissions on the agent binary
Ran the agent binary manually to verify connectivity

Now for the automatic run on startup. Even though my RPi will be running all the time, I wanted to ensure the agent would run on startup in case of a reboot or power outage. I tried several things, including crontab and the rc.local file, but ultimately got it to work by adding the following line to the /etc/rc.local file before the exit 0:

(sleep 10;/usr/sbin/agentfilename)&

I had tried it without the "sleep 10" before and it didn't work. I searched the internet for running tasks on RPi startup and came across this page:

https://stackoverflow.com/questions/504 ... ab-systemd

The page refers to a python script but the situation is similar. Adding the sleep command allows the RPi to wait until other things have loaded before trying to run the agent. The number of seconds may change depending on your RPi performance, so it may take some experimenting to get it to work. But with that added to the rc.local file, the agent runs automatically after every reboot

Post Reply