Restart network without reboot ?

Juergen Nickelsen ni at w21.org
Mon Feb 10 16:46:34 UTC 2014


On 10.02.2014 17:30, dteske at FreeBSD.org wrote:
> $ cat << EOF > /tmp/do_it_now.sh
> #!/bin/sh
> service netif restart
> dhclient em0
> dhclient em1
> EOF
> 
> Then add a line to your /etc/crontab that will fire in the next 1-2
> minutes...
> 
> sh -c 'echo "$((($(date +%M)+2)%60)) $(date +%H) * * * root sh
> /tmp/do_it_now.sh" >> /etc/crontab'
> 
> NB: That's a single command to be entered on a single line
> 
> Then just wait a minute or two, you'll get kicked out, start a ping, and
> when
> it starts responding on the new IP address (hopefully you know what this is)
> you can log in on the new address.
> 
> Of course, the next thing you should do is to edit /etc/crontab to remove
> the
> entry else the same time tomorrow it will reset your network.
> 
> Lastly, remove the /tmp/do_it_now.sh script.

Is there any special reason you don't just

    $ echo 'service netif restart; dhclient em0; dhclient em1' | at now

, which looks so much easier to me?

Of course, at(1) drags your whole environment into the job, which may be
not what you want. I wouldn't see much harm in this case, though.

Regards, Juergen.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 555 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20140210/13dd8551/attachment.sig>


More information about the freebsd-questions mailing list