Need help with a scheduled reboot cron job via Webmin
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
Need help with a scheduled reboot cron job via Webmin
Greetings
I am quite new with Linux. I have recently built a home Ubuntu server (14.04). I am wanting to schedule a daily reboot of the server at a specific time. I have Webmin installed so assuming it should be a bit easier to do this task via Webmin. My understanding is to do this via Webmin, I would create a new scheduled cron job, however I am having some difficulty determining what I enter for the cron job. I assume that I would execute the cron job as the a user with root privileges. In the Command box, would I simply enter
reboot
or would it be
0 */3 * * * /sbin/reboot
Also, do I need to enter anything in the Input to command box?
I wasn't sure what "0 */3 * * * /sbin/reboot" actually represented. I found that in a Google search. Someone else was trying to do the same thing. I only want the system to reboot once a day, say at 7am. I can see that I can control the reboot time via Webmin. I assume under "Hours" I would just select 7, although I am a bit confused how to set the time.
So back to my original question, is the only entry that I need to place into the Command box is "reboot"? Or is there more to it than that?
Execute as: root
Active: Yes
Command: /sbin/shutdown -r now
Input to Command: <blank>
Description: HOURLY reboot
I just played with running it every 2 hours by selecting 0,2,4,..,22 under the "Selected Hours", but it would run on reboot. I think this might be a bug in the way it triggers the Cron Job. So I've adjusted it to only have the value '2' selected under hours. I'm hoping this will bounce in about 90 minutes on it's own.
I think you want:
When to execute: Daily (at midnight) ... not 7am, but at least it's clear.
Every time I use any of the Webmin options other than the built in "hourly / weekly / etc" they all execute on reboot. and when that script is a reboot script? ... you guessed it. Luckily there's a little lag and I was able to get in and disable the reboot before the turn of of the minute. Very frustrating.
If I may, automatic reboots are not the best idea. Maybe it was a fluke but I had my server on cronjob reboots once a week, one day it rebooted at 12am sunday morning, i didnt find out till 730pm that day that it had crashed and hadn't rebooted properly. Everyone on the property was without internet all day because of that. You don't need to do it daily, but it should be done manually to make sure it all comes back up properly. my 2 cents.
I was doing it hourly because my SMB shares from it kept dying. They seem to have stabilized, and for me it's just a hobby rPi that lives on VPN for random torrents. Truthfully. Almost never used. But I agree with you if it's an important Linux box.
One of the main reasons to use linux servers is because they don't have to be rebooted periodically. I've seen public servers run for two years uptime and that ended only because of a power and UPS failure.
Now that I think about it. I should've scheduled the Samba service to recycle. HRM. Damn it. Now that I know more I'll change it. Maybe even write a little monitoring script that bounces the service if needed.
[edit]
added an hourly samba bounce. I wasn't able to use "restart" if the service was stopped for some reason. Maybe the SH for 'restart' isn't a stop/start, or doesn't handle errors well. So I compounded it with a stop/start myself which works.
Run-As: root
Command: service smbd stop; service smbd start
Schedule: hourly
[edit2]
Did the same for my VPN (I'm researching how to monitor this to auto bounce when needed) too.
Command: nmcli con up My_VPN_Connection_Name_NOT_ID
-----ex: nmcli con up ExpressVPN
Last edited by SP3NGL3R; 06-16-2017 at 09:15 PM.
Reason: added new script for bouncing SMB Daemon, and VPN connection
I'd be more inclined to find out why they are dying. That is not normal behavior by any stretch of the imagination. Something else is going on, have you checked out the logs? I reboot my server once every 2 weeks, only because I feel I should. But I haven't had a single process or service just randomly stop yet. Been running fine for a couple years now, including my samba service.
I checked with my VPN provider and the short answer is that they drop idle connections. They don't offer an "always on" solution. So it's up to me to keep it alive. I've considered just running an IP Trace (dig) every couple minutes just to keep it up. But haven't implemented yet.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.