I have a Raspberry Pi that I’m using in different environments. The easiest way to use the Pi is by just connecting power and network and use SSH, but when theres no screen, it’s not always easy to know the IP address of my Pi.

To make life easier for myself i have put the following lines in a start.sh script and added it to my crontab with the @reboot option. This will make crontab run this script every time the Pi has been rebooted (or shut down)

sleep 30
echo “My IP is: $(ip addr | grep global | awk -F ‘ ‘ ‘{print $2}’)” | mail -s “Raspi reporting in…” [email protected]

The script will put in a 30 seconds delay to allow the Pi to pickup an address and then mail it for my mail address. Remember to make sure that your Pi is able to send mails, otherwise this will not work.

This will most likely ensure that i will get a mail with the IP address of my Pi, and I  am ready to login with SSH.



Leave a Reply

Your email address will not be published. Required fields are marked *

Are you human? * Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.