Score:0

Run python script when internet connection becomes available on Jetson Nano (Ubuntu 18.04)

in flag

I need to setup a Jetson Nano device so that a Python script is launched everytime an Internet connection is available.

So, referring to this question, I did the following:

  • I created the 'run_when_connection_available' script:
#!/bin/sh

# create a dummy folder to check script execution
mkdir /home /user_name/dummy_folder_00

# kill previous instances of the system
pkill python3

# move to folder with python script and launch it
cd /home/user_name/projects/folder
/usr/bin/python3 launcher.py --arg01 --arg02 ...

# create another dummy folder to check script execution
mkdir /home /user_name/dummy_folder_01

  • I made this script executable and I copied it to /etc/network/if-up.d

Now, everytime I plug the ethernet cable out and in again, I can see the dummy folders are created in /home/user_name, but the python script isn't launched (at least, it doesn't appear in the system monitor). I tried running the command in the script from the terminal, and everything works fine, the python program starts as expected. Am I doing something wrong?

Score:0
it flag

I've written a bash script to help with this: https://github.com/waltinator/net-o-matic It watches the connection, and when the connection drops, does a user-specified thing to try to reconnect.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.