I have a linux box connected to a router via an ethernet cable. The cable is never unplugged and the linux box is always on. My goal is to have a command executed on the linux box every time the router is rebooted.
This question is quite similar to this question but the suggested solution doesn't seem to work. More specifically:
- the command
inotifywait -e modify /sys/class/net/eth0/carrier; echo 'Change detected'
does never detect a change (even in the case the cable is unplugged from the pc), because according to this answer the commandinotifywait
does not work in/sys
- the command (suggested in a comment)
inotifywait -e modify /etc/network/if-up.d/avahi-daemon
does not detect any change when the router is rebooted