Rebooting Linux machine at midnight everyday
Rebooting Linux machine at midnight everyday
Has someone got any ideas?
I need to automatically reboot a server everyday at midnight and it has do so before the login prompt (ie the computer boots and is left alone at the login prompt). The server is running a late version of RedHat. It has an application called KCron in Gnome which doesn't work. The command I'm trying to schedule for execution is /sbin/shutdown -r 23:59 but it doesn't run it, even if I'm logged in.
If I enter shutdown -r 23:59 manually in the terminal, it works. I have also tried to place this command in /etc/rc.d/rc.local without success. All my other programs run successfully called from rc.local, they run in the background before any user has logged on.
Any help would be greatly appreciated!
I need to automatically reboot a server everyday at midnight and it has do so before the login prompt (ie the computer boots and is left alone at the login prompt). The server is running a late version of RedHat. It has an application called KCron in Gnome which doesn't work. The command I'm trying to schedule for execution is /sbin/shutdown -r 23:59 but it doesn't run it, even if I'm logged in.
If I enter shutdown -r 23:59 manually in the terminal, it works. I have also tried to place this command in /etc/rc.d/rc.local without success. All my other programs run successfully called from rc.local, they run in the background before any user has logged on.
Any help would be greatly appreciated!
DFI LanParty X48 LT-2TR
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
Re: Rebooting Linux machine at midnight everyday
CPU: AMD Phenom II X2 555 (OC'ed to 3.8Ghz)
CPU Cooler: CM Hyper TX3 P/P
GPU: Sapphire Radeon HD5850
Motherboard: Asus M4A785T-M
Memory: 4GB Corsair XMS3 DDR3 1333
Case: Zalman Z7
Display: Samsung Syncmaster 2243BWX
CPU Cooler: CM Hyper TX3 P/P
GPU: Sapphire Radeon HD5850
Motherboard: Asus M4A785T-M
Memory: 4GB Corsair XMS3 DDR3 1333
Case: Zalman Z7
Display: Samsung Syncmaster 2243BWX
Re: Rebooting Linux machine at midnight everyday
Linux, please. That's for Windows.
DFI LanParty X48 LT-2TR
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
Re: Rebooting Linux machine at midnight everyday
Hex I am no Linux fundie, but maybe it is failing to run as it doesn't have the credentials?
I'm thinking a Linux equivalent of "Run as..."
I'm thinking a Linux equivalent of "Run as..."
to ápeiro anima
-
- Registered User
- Posts: 1321
- Joined: 04 Nov 2007, 02:00
- Location: /home/jhb/fourways
Re: Rebooting Linux machine at midnight everyday
and you can't make a shell script to run it?
put that into a script, save script then make executable, then add that to the rc.local?
otherwise try use cronjob/crontab Wikipedia Cron
edit: As urban said, may be that only root can exec shutdown, so you need a way to exec the script as root
Code: Select all
#! /bin/sh
shutdown -r 23:59
otherwise try use cronjob/crontab Wikipedia Cron
edit: As urban said, may be that only root can exec shutdown, so you need a way to exec the script as root
Re: Rebooting Linux machine at midnight everyday
I'm running it as root but thanks for the ideas. I will try them.
DFI LanParty X48 LT-2TR
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
- rustypup
- Registered User
- Posts: 8872
- Joined: 13 Dec 2004, 02:00
- Location: nullus pixius demonica
- Contact:
Re: Rebooting Linux machine at midnight everyday
correct... anacron and "init 6", if you want to force the issue, else a simple shutdown script, (root owned)...
Most people would sooner die than think; in fact, they do so - Bertrand Russel
Re: Rebooting Linux machine at midnight everyday
OK sorted. When I first tried to set it up I messed up the boot by putting shutdown -r 23:59 in rc.local without an & afterwards so the PC couldn't boot (without the & the shutdown will block continued execution).
Another guy "fixed" the rc.local file for me by booting with a USB drive and editing the file. Whatever he used to edit the file removed the execution rights on rc.local for all users which completely prevented rc.local from running at start up. Executing "chmod a+x rc.local" fixed the problem...
This is one of the reasons I would prefer to stay away from Linux. It would be fine if it wasn't for work and I was just messing around but this tiny, little problem cost me a few hours.
Another guy "fixed" the rc.local file for me by booting with a USB drive and editing the file. Whatever he used to edit the file removed the execution rights on rc.local for all users which completely prevented rc.local from running at start up. Executing "chmod a+x rc.local" fixed the problem...
This is one of the reasons I would prefer to stay away from Linux. It would be fine if it wasn't for work and I was just messing around but this tiny, little problem cost me a few hours.
DFI LanParty X48 LT-2TR
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
Re: Rebooting Linux machine at midnight everyday
Thanks, I'll remember that for the future if I ever want to schedule something else.rustypup wrote:correct... anacron and "init 6", if you want to force the issue, else a simple shutdown script, (root owned)...
DFI LanParty X48 LT-2TR
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
- rustypup
- Registered User
- Posts: 8872
- Joined: 13 Dec 2004, 02:00
- Location: nullus pixius demonica
- Contact:
Re: Rebooting Linux machine at midnight everyday
ouch...Hex_Rated wrote: this tiny, little problem cost me a few hours.
one of the reasons we don't run as root... bypassing these controls generally results in drama....
Most people would sooner die than think; in fact, they do so - Bertrand Russel
Re: Rebooting Linux machine at midnight everyday
Wont Init 6 shut it down as in switch off ?rustypup wrote:correct... anacron and "init 6", if you want to force the issue, else a simple shutdown script, (root owned)...
When you use kcron. When are you running the schedule? cus you are already scheduling the shutdown command at 23:00
so cron runs the command at 23:00 and a second later you tell it to run at 23:00 so it will shut down only the next day.
Which it probably wont cus of the reboot.
Why not run the shutdown command at start up ?
so everytime it starts up it will issue the shutdown command for 23:00
- rustypup
- Registered User
- Posts: 8872
- Joined: 13 Dec 2004, 02:00
- Location: nullus pixius demonica
- Contact:
Re: Rebooting Linux machine at midnight everyday
6 is reboot... unless red hat makes its own init rules in this regard....SBSP wrote:Wont Init 6 shut it down as in switch off ?
and the real issue was someone had removed exec rights from the rc script... hence its being ignored at boot...
Most people would sooner die than think; in fact, they do so - Bertrand Russel
-
- Registered User
- Posts: 20576
- Joined: 19 Sep 2003, 02:00
- Location: Bloodbank
Re: Rebooting Linux machine at midnight everyday
Nope that is init 0SBSP wrote:Wont Init 6 shut it down as in switch off ?rustypup wrote:correct... anacron and "init 6", if you want to force the issue, else a simple shutdown script, (root owned)...
- Spoiler (show)
Re: Rebooting Linux machine at midnight everyday
Don't blame the Linux, it was doing exactly what you told it toHex_Rated wrote:This is one of the reasons I would prefer to stay away from Linux. It would be fine if it wasn't for work and I was just messing around but this tiny, little problem cost me a few hours.
Re: Rebooting Linux machine at midnight everyday
Not really hey, editing a file shouldn't remove execution privileges.Kasyx wrote:Don't blame the Linux, it was doing exactly what you told it to
DFI LanParty X48 LT-2TR
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
Re: Rebooting Linux machine at midnight everyday
I never really understand the permission thing.
I once got permission denied errors so i ran a chmod 777 *.* -R in the root (On a production Spamfilter)
After the reboot nothing worked. I still dont know why , all i know it i wont do it again.
I once got permission denied errors so i ran a chmod 777 *.* -R in the root (On a production Spamfilter)
After the reboot nothing worked. I still dont know why , all i know it i wont do it again.
Re: Rebooting Linux machine at midnight everyday
SBSP wrote:I once got permission denied errors so i ran a chmod 777 *.* -R in the root (On a production Spamfilter)
After the reboot nothing worked. I still dont know why , all i know it i wont do it again.
- rustypup
- Registered User
- Posts: 8872
- Joined: 13 Dec 2004, 02:00
- Location: nullus pixius demonica
- Contact:
Re: Rebooting Linux machine at midnight everyday
the file wasn't edited... it was replaced, (by root - who is supposed to know what s/he's doing) - new documents in a *nix environment are created as non-executable by default, (for really obvious reasons).Hex_Rated wrote:editing a file shouldn't remove execution privileges.
@SBSP: that's the oldest joke in the book... if you really fell for it, you need to seek revenge on the individual who suggested it
Most people would sooner die than think; in fact, they do so - Bertrand Russel
Re: Rebooting Linux machine at midnight everyday
No one sugested it , like i said i got permission errors so i checked up on how to change permissions.rustypup wrote:the file wasn't edited... it was replaced, (by root - who is supposed to know what s/he's doing) - new documents in a *nix environment are created as non-executable by default, (for really obvious reasons).Hex_Rated wrote:editing a file shouldn't remove execution privileges.
@SBSP: that's the oldest joke in the book... if you really fell for it, you need to seek revenge on the individual who suggested it
found that chmod 777 does this.
When i tried to install squid it kept telling me permission denied when i fix the problem i run the install again
it gave me permission denied errors on the next folder, kept fixing it for about 5 different directories.
So i got fed up and decided to do the whole drive.
Re: Rebooting Linux machine at midnight everyday
I use Kate to edit files under normal circumstances and execution rights aren't removed. But yeah, I get what your saying. I'll give root a good kick up the a$$ next time he walks past my office.rustypup wrote:the file wasn't edited... it was replaced, (by root - who is supposed to know what s/he's doing) - new documents in a *nix environment are created as non-executable by default, (for really obvious reasons).Hex_Rated wrote:editing a file shouldn't remove execution privileges.
Linux equivalent of delete system32 to make your PC faster.@SBSP: that's the oldest joke in the book... if you really fell for it, you need to seek revenge on the individual who suggested it
DFI LanParty X48 LT-2TR
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
Intel Q9450 @ 3.2Ghz
Dell 24" 2408WFP | Phillips 37" 1080p
Sapphire HD4870 X2 2GB
4GB Corsair DDR-2 1066 | Thermalrite 120 Ultra Extreme | G9 Mouse | G15 Keyboard
Vista Ultimate x64
Re: Rebooting Linux machine at midnight everyday
thanks now my PC is broken.Linux equivalent of delete system32 to make your PC faster.
-
- Registered User
- Posts: 3129
- Joined: 22 Sep 2008, 11:16
- Location: stuck in my own world
Re: Rebooting Linux machine at midnight everyday
type crontab -e if you have it on your system and put in this line
23 00 * * * /sbin/init 0
and it should coz your machine to shutdown everyday at that time
i could have the exact command wrong though not quite sure if it doesnt work you could replace /sbin/init 0 with /sbin/shutdown -t now taht might work as well
23 00 * * * /sbin/init 0
and it should coz your machine to shutdown everyday at that time
i could have the exact command wrong though not quite sure if it doesnt work you could replace /sbin/init 0 with /sbin/shutdown -t now taht might work as well
THE GAME........YOU Have JUST LOst It !!!!!!!!!!
Re: Rebooting Linux machine at midnight everyday
I think the problem is sortedRyan_Cooper wrote:type crontab -e if you have it on your system and put in this line
23 00 * * * /sbin/init 0
and it should coz your machine to shutdown everyday at that time
i could have the exact command wrong though not quite sure if it doesnt work you could replace /sbin/init 0 with /sbin/shutdown -t now taht might work as well