The issue is almost certainly that your
@reboot cron job has started before your network interfaces have come
up. This is, in general, a well-documented shortcoming of
cron. It doesn't mean the
@reboot facility is useless, it just means you need to understand how it works, and how to work around it when it fails - as it has in your case (probably :).
There are at least 2 ways to do this:
sleep in your @reboot job to give the network more time to get
crontab entry will look something like this: :
@reboot sleep 10; /your/bash/script/as-it-is-now
I suggested the value of
10 here to give the interface 10 seconds to come
up; YMMV, so experiment with different values.
- following up on @confetti 's suggestion (and with thanks to @Celada), put your script in
/etc/network/if-up.d. Following is a prototype that may be useful. Note that it only runs the first time your system comes up (like
@reboot, and NOT each time the network interface is brought
# note that /var/run is a temp fs, and so a system shutdown
# will effectively erase our flag file, 'the-network-is-up'
case "$IFACE" in
# Exclude the loopback interface; we won't consider it
# as it's not a true interface. We set the flag only
# when a true network interface comes up
# if the flag file exists, we're done here
# otherwise, we'll create it
if [ -e $NWKSTATUS ]; then
# add your script here...
So - put all of the above into a file (e.g.
setnwkstatus.sh), then save it in the folder
/etc/network/if-up.d/ and make it executable (i.e.
sudo chmod /etc/network/if-up.d/setnwkstatus.sh )