"Network Is Unreachable" Error for Bash Script at Startup

I have a bash script that is run at startup on an Odroid running Ubuntu Mate. The script connects to the wifi and then calls a python script which makes a http request:

...
nmcli dev connect NETWORKNAME password PASSWD
python my_script.py
...

This script works when I call it after boot. However, when it is called during boot, the "Network is unreachable" error is thrown. I tried to use the ethernet connection but the result is the same. Also, adding a sleep 30 command before calling the python script doesn't work. How can I solve this problem?

1
David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article