0

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?

Carlo
  • 203

1 Answers1

0

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.

waltinator
  • 36,399