LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need help with a scheduled reboot cron job via Webmin (https://www.linuxquestions.org/questions/linux-newbie-8/need-help-with-a-scheduled-reboot-cron-job-via-webmin-4175545699/)

torbuck 06-17-2015 11:08 PM

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?

Thanks for any help on this

Cheers,

Torbuck

Habitual 06-18-2015 04:35 PM

Every 3 hours? I think not!
but ok.
have a look at http://www.dataphyx.com/cronsandbox/cronsandboxgui.php and enter
Code:

0 */3 * * *
there and hit the run button for what it will "do" and when.

torbuck 06-19-2015 12:03 AM

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?

SP3NGL3R 06-15-2017 02:46 PM

Here's my setting for HOURLY (on the hour)
 
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.

SP3NGL3R 06-15-2017 09:30 PM

no clue
 
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.

jmgibson1981 06-16-2017 04:50 PM

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.

SP3NGL3R 06-16-2017 05:51 PM

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.

scasey 06-16-2017 05:54 PM

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.

SP3NGL3R 06-16-2017 08:12 PM

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

jmgibson1981 06-17-2017 02:48 PM

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.

SP3NGL3R 06-18-2017 10:56 PM

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.


All times are GMT -5. The time now is 08:21 AM.