I'm trying to get my Raspberry Pi 2 to automatically email its IP address when it boots. I included my entire /etc/rc.local file below for reference. When I manually run the file, I get an email with the Pi's IP address, as expected. It has never worked automatically when booting. Why doesn't email script run on boot as expected and how do I fix it? I tried removing the ampersand (&) and its presence did not make a difference.
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. # Print the IP address _IP=$(hostname -I) || true if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" python /home/pi/code/startup_mailer.py & fi exit 0