LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to reboot linux machine automatically (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-reboot-linux-machine-automatically-347722/)

kum4363 07-28-2005 01:09 PM

How to reboot linux machine automatically
 
How do I perfom a unattended linux reboot at a particular time- say at 10 p.m. every night.
Will the command "shutdown -h 22:01 -r now" work? If not what is the right command. Thanks

LuggerHouse 07-28-2005 01:29 PM

You better use the /etc/cron.daily directory..

Simply create a script with
shutdown -r now

and place it there. I will be executed ad per crontab entry for the daily directory.

HTH
LuggerHouse

halo14 07-28-2005 02:58 PM

yeah.. that will work.. but umm... why are you wanting reboot daily?? Are you new to Linux/Unix?? These systems won't slow down from being turned on for long periods of time.. the only thing that isn't hardware related that you NEED to reboot Linux for is if you install a new kernel, you have to reboot in order to load the new kernel..

Matir 07-28-2005 03:18 PM

Or you could accomplish it like so:
Code:

ln -s /sbin/reboot /etc/cron.daily/reboot
;)

No scripts needed.

J.W. 07-28-2005 07:36 PM

Automating a reboot is not hard to do, but the important point really is "Why would a daily reboot be necessary?" Unlike Windows, which is prone to becoming unstable the longer it has been runnning, Linux can easily run for months if not years without a reboot. (At least for me, the only time I need to reboot is when I need to switch over to Windows on my dual boot machine). As halo14 mentioned, there are not many situations where a reboot in Linux is truly required.

Is your question really more related to how to set up an automated task (and is just using the reboot simply as an example) or is there some sort of problem that you are hoping that a reboot will solve? -- J.W.

perfect_circle 07-28-2005 09:05 PM

Actually according to my experience, after a period of time, linux runs faster that in the beginning.
Linux utilizes the RAM in a very efficient way. SO it tries to make use of all the RAM you have and the stuff you load in RAM will stay there unless you need the space. So applications like firefox that may need 3-4 second to load the first time will load pretty fast next time. I don't have a server, but I tend to leave my box switched on for weeks and never had a problem. The only time you need to reboot is when you load a new kernel.
For anything else you may need to switch yo run level 1, and install it, but rebooting is almost never necessary.

*EDIT*
If you experience slow downs in most cases it's a memory leak or a bug in one of your programs and tool like "top" or "htop" will help you determine and kill/unload the buggy application.

enemorales 07-29-2005 01:56 AM

May I ask the complementary question: If you dont need your machine turned on during night, why should you do so?

grimse 07-29-2005 02:18 AM

you also can use crontab. simply login as su, type '/usr/bin/crontab -e', set a time and the comand. for 10 p.m. its:
0 22 * * * /usr/bin/shutdown -r now

grim

hakukani 07-29-2005 01:51 PM

enemorales-

Linux boxes run their daily cron scripts early in the morning--I think the default is 2:30 am-?...

In general, though, most electronic devices run better and more reliably the more they are left on. Powering on and off eventually will stress the components of the power supply, making it more likely to fail. In Hawaii, or any humid environment, the corrosion level is very high. I leave all of my electronic equipment on most of the time, and I find that I have much less corrosion.

I have a twenty-two year old audiophile stereo system that has rarely been shut off; a Kurzweil keyboard, and various audio hardware that has rarely been turned off in five years; a pII from mid-1998 that has never had a hardware problem [ok, the windmodem kacked, so I had to replace it with a better one] (my server), plus some newer boxes. Only my laptop gets regularly powered up and down, because I transport it from work to home daily.


my $.02


All times are GMT -5. The time now is 12:37 PM.