Alan_s Alan_s - 10 months ago 92
Linux Question

How to automatically run Python script AFTER Raspberry Pi fully boots?

My script is /home/ and it is using the Bottle web framework. My script needs to run after Raspberry Pi has connected to my local network. If I try to automatically run it on the boot, it doesn't work because the network connections just aren't ready yet.

I know I can I use "crontab -e" and add @reboot sleep 60 seconds -- but I don't think a sleep is too reliable.

All other "run script on boot" questions I've seen don't help because they run the scripts too early in the bootup process.

Is there anyway to check if the raspberry pi has connected and then have my python script automatically run?

Answer Source

You may add your code at "/etc/network/if-up.d/upstart" just after "all_interfaces_up" like this:

all_interfaces_up() {
    # return true if all interfaces listed in /etc/network/interfaces as 'auto'
    # are up.  if no interfaces are found there, then "all [given] were up"

Where "/your/code/path/" is your code location