LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 06-17-2015, 11:08 PM   #1
torbuck
LQ Newbie
 
Registered: Jun 2015
Posts: 7

Rep: Reputation: Disabled
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
 
Old 06-18-2015, 04:35 PM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
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.
 
Old 06-19-2015, 12:03 AM   #3
torbuck
LQ Newbie
 
Registered: Jun 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
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?
 
Old 06-15-2017, 02:46 PM   #4
SP3NGL3R
LQ Newbie
 
Registered: Jun 2017
Posts: 5

Rep: Reputation: Disabled
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.
 
Old 06-15-2017, 09:30 PM   #5
SP3NGL3R
LQ Newbie
 
Registered: Jun 2017
Posts: 5

Rep: Reputation: Disabled
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.
 
Old 06-16-2017, 04:50 PM   #6
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,135

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
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.
 
Old 06-16-2017, 05:51 PM   #7
SP3NGL3R
LQ Newbie
 
Registered: Jun 2017
Posts: 5

Rep: Reputation: Disabled
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.
 
Old 06-16-2017, 05:54 PM   #8
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,708

Rep: Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210
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.
 
Old 06-16-2017, 08:12 PM   #9
SP3NGL3R
LQ Newbie
 
Registered: Jun 2017
Posts: 5

Rep: Reputation: Disabled
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
 
Old 06-17-2017, 02:48 PM   #10
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,135

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
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.
 
Old 06-18-2017, 10:56 PM   #11
SP3NGL3R
LQ Newbie
 
Registered: Jun 2017
Posts: 5

Rep: Reputation: Disabled
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron job scheduled to the server after logging in via ssh login doest not run surekag Linux - Newbie 4 02-12-2014 08:15 AM
Webmin - Scheduled Cron Job - Password! tfranklin Linux - Server 5 01-20-2010 07:08 PM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
How can i erase emails via a cron job in Webmin? epamuk General 1 11-09-2007 07:39 AM
What does cron do if machine is down when job is scheduled? Utah Linux - Software 4 08-24-2005 07:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration