-1

I need to launch a command everytime I connect to internet and I was looking to find a way to automate it

I looked on the crontab but it does't seem as far as I know to allow such automation

There is any way to do this?

I would appreciate your help

Thanks

1 Answers1

0

You can start a script after the linux box gets connected using up (requires ifplugd to be installed )

#/etc/network/interfaces
auto eth0
    iface eth0 inet dhcp
    up /etc/network/yourscript.sh

However, there keep in mind that if you disconnect the cable (and plug in in after a while), the script also starts even though the router might not have been restarted.

--edit--

alternatively , place your script in

/etc/network/if-up.d/ (make sure it is executable and restart networking after changes.)