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:
#!/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
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?
Ok, I guess it was a matter of permissions, I solved it by running everything as user_name, so I modified the script as
sudo -user user_name /usr/bin/python3 launcher.py --arg01 --arg02 ...