LinuxQuestions.org
Help answer threads with 0 replies.
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 12-16-2006, 07:37 AM   #1
cool_ahm
LQ Newbie
 
Registered: Feb 2006
Location: India
Distribution: Fedora 6 ,Knoppix 5.1 ,FreeBDS 6.2
Posts: 2

Rep: Reputation: 0
restart system periodicaly


hi

i want to a script for restarting my rehat box at an interval i would define

now for this i have already tried paying with crontab

but whatever synapse i give in crontab

that is "* * * * * <command to executed>"

it does not work here i tried "shutdow now -r" and all other method but it does not restart by it self

some one told me that insted of giving shutdown command in cron i will have to write a sript file with shutdown command and the execute this file in crontab with the time field

pls help
 
Old 12-16-2006, 07:40 AM   #2
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 416Reputation: 416Reputation: 416Reputation: 416Reputation: 416
Welcome to LQ!

Um, not to be offensive, but why in the world would you want to automatically reboot periodically? Is there a specific problem you are trying to solve? If so, please post it because I'm pretty sure there is a better way to deal with it than a reboot.
 
Old 12-16-2006, 08:34 AM   #3
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware 14.1 (32 and 64 bit)
Posts: 1,594

Rep: Reputation: 124Reputation: 124
Besides Hangdog's comment you have to give the full path to the command you want to execute. That's true for all crontab entries, or you can set crontab's own PATH variable at the top of your crontab file. So try "/sbin/shutdown" instead of "shutdown" if you have a good reason to restart it the way you want.
 
Old 12-17-2006, 11:12 PM   #4
cool_ahm
LQ Newbie
 
Registered: Feb 2006
Location: India
Distribution: Fedora 6 ,Knoppix 5.1 ,FreeBDS 6.2
Posts: 2

Original Poster
Rep: Reputation: 0
thanks for teh reply
but i acuatly tried that also

for example " 5 0 * * * /sbin/shutdown now -r "
& " 5 * * * * /sbin/shutdown now -r "
then i wrote a file where i mentioned this command shutdown now -r, and then made it executale by "CHMOD file 777"
the file when run executes the job perfectly

then i tried using the file in crontab

with "5 * * * * <file> "

but that also did now work

pls help tell me where i am wrong
 
Old 12-17-2006, 11:37 PM   #5
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
Quote:
Is there a specific problem you are trying to solve?
Sounds like the instructor still has a nervous twitch left over from using MS.
Kind of looks like just getting practice with crontabs.
 
Old 12-18-2006, 07:52 AM   #6
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware 14.1 (32 and 64 bit)
Posts: 1,594

Rep: Reputation: 124Reputation: 124
Did you give the full path to this "file" -- I guess you are talking about a Bash script?
 
Old 12-18-2006, 03:00 PM   #7
Vgui
Member
 
Registered: Apr 2005
Location: Canada
Distribution: Slackware
Posts: 496

Rep: Reputation: 31
Or you could drop a 'shutdown -r now' script into the /etc/cron.daily/ or /etc/cron.weekly/ folders, and let cron worry about the rest.

Another cruder option would be using 'at' to schedule a reboot when the system is started up (and set at for +12 hours or whatever).

Seems weird to want to restart that often.
 
Old 12-18-2006, 07:38 PM   #8
J.W.
LQ Veteran
 
Registered: Mar 2003
Location: Boise, ID
Distribution: Mint
Posts: 6,642

Rep: Reputation: 83
I think the better question still remains what Hangdog42 asked: *Why* is a periodic reboot being considered? Linux can run for months without needing to reboot, and unlike Windows which can become unstable over time, there shouldn't be any regular need to schedule a reboot. Besides, it's dangerous - to use just one simple example, if you are running a database and one of your users submits a process that will generate a large series of transactions (for example, running a payroll cycle for a few hundred employees), having the machine reboot in the middle of things is going to create a mess. What is the basis for wanting to schedule a reboot?
 
Old 12-18-2006, 07:50 PM   #9
Tortanick
Member
 
Registered: Jul 2006
Distribution: Debian Testing
Posts: 299

Rep: Reputation: 30
try scheduling the task as root or adding the SUID bit to /sbin/shutdown

I would listen to those above saying its a bad idea though
 
  


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
Restart in Linux hangs system omega21 Linux - Hardware 4 03-29-2007 02:48 PM
restart USB system pajamabama Linux - Hardware 0 06-14-2006 08:12 PM
System hangs up on restart and shut down darknails Fedora 7 01-24-2005 05:04 AM
Bash?? System Restart (shutdown -r now) woranl Linux - Newbie 4 04-13-2004 10:33 PM
Restart system FredrikN Linux - General 5 12-15-2001 11:19 PM


All times are GMT -5. The time now is 04:50 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration