[SOLVED] How to schedule a restart of networking after a reboot
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to schedule a restart of networking after a reboot
I have two machines where upon reboot, sometimes eth0 will go down once the logon prompt appears. Based on constant pings, it does come up during the boot process but then something happens around when the logon screen appears to makes it stop responding. And this doesn't happen at every boot, but enough to where it's caused issues/pain.
I've never been able to figure out why, but I'm wondering if there's some sort of workaround I can do by maybe scheduling a cron job to start/restart eth0 like a minute or two after reboot, that way regardless it will be up after that.
I know, very cheesy and not ideal, but it would get me through till those machines are retired.
You can typically run a cronjob at reboot. @reboot in a crontab is something that I have used quite a bit to run something after we have rebooted a server.
Gnome makes an assumption that the network shouldn't be available until a user logs in. This can usually be corrected by marking the inteface "not configurable by users".
Their default is gnome - so if you are using gnome then you likely have the problem that Gnome is turning the network OFF under the assumption that only the logged in user will turn it on.
The final symptom is that if the user logs out, the network is again disabled...
Maybe that's it. My server boots to a CLI logon prompt though, but maybe gnome is running/installed?
Although the network never turns itself off after I manually restart it if it dies when the logon prompt appears. Unless maybe that's because some system account "logs in" but never logs out due to running processes?
but it is possible that the elements required by Gnome are. Things like the credential managment crap, logind, and some others that got grafted into the system. These are useful in some areas, but just cause more problems most of the time for servers.
Just more complex than it needs to be.
Whether that gets the root login identified as never logging out I'm not sure. But marking the interface "not under user control" should stop it from shutting the network down.
BTW, the cron restart might fix it... and it might not. Cron is usually started at the same time as the interactive logins. If it happens to run first, I would expect it to fail as the network would still be up. And then be shutdown by whatever is doing it now.
On my system I have the /etc/sysconfig/network-scripts/ifcfg-eth0 (or whatever you name it marked as "NM_CONTROLED=no", and "ONBOOT=yes".
What I'm not sure of is how much NetworkManager does with this. I gave up on it, and use the legacy network startup. But that is just because I don't remember. I think the network is started anyway, but once started, it is ignored by NetworkManager - thus it isn't under user control.
All of the current RH releases have been using NetworkManager to handle the startup/shutdown of networks, and to provide a service daemon that users can interact with to start/stop those they are permitted to control.
Without that entry (being specifically set to "no"), I think NetworkManager assumes control.
My servers kinda old, is there a way to tell if mine uses that setting? I tried man ifcfg but it said a man page didn't exist.
NM_CONTROLLED appears since RHEL 6.X, it doesn't appears in earlier versions of RHEL.
You check the ifcfg-eth0 configuration, is ok? Do you review the dmesg/messages/boot files in /var/log/?
Maybe a work around, it would be put a crontab with a script that will check the networks and when something is wrong (link down), it can restart the network service. Anyway the case is really strange, because the network service starts after the file system check.
Last edited by Stvrosky; 08-13-2014 at 04:37 PM.
Reason: Add information
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.