LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 08-07-2004, 01:19 AM   #1
flamesrock
Member
 
Registered: Aug 2003
Distribution: Gentoo 2006.1
Posts: 405

Rep: Reputation: 30
Automatically Restart Server??


OK, here's the problem:

My slackware 9.1 server tends to loose consciousness every 4 - 10 days, and the only way to prevent this is to give it periodic reboots. Is there a simple way I can tell it to restart automatically after a certain period of time?

Also, I'm not sure that I have the cron job daemon running (if such a thing exists,) so how might I enable it? The reason I ask is because I'll be going away for two weeks and it needs to keep chugging during that time.

-thanks in advance
 
Old 08-07-2004, 03:04 AM   #2
louishp
LQ Newbie
 
Registered: Mar 2004
Posts: 13

Rep: Reputation: 0
Thumbs up

You should be able to use a cron job to restart the box.

But if it's an important server or anything along the lines why don't you try and narrow down the "consciousness" problem is there a process that needs to be stopped\started or do you have underlying hardware problems or even your power config is incorrect, having a machine restart itself can be usefull but also in my experience can lead to bigger problems (like the server not comming up).

But anyhow to create a cronjob using crontab do the following:

crontab -e #this will put you into a session with your default editor (vi \ nano)

SHELL=/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin
HOME=/var/log
MAILTO=(email address)

0 0 1,15 * * shutdown -r now # midnight on the 1st and the 15th of each month

save the file and your done,

Try this website (it has an autocrontab generator): http://htmlbasix.com/crontab.shtml

But it's a useful tool and you would probably want to read up on it:

http://kb.indiana.edu/data/afiz.html
 
Old 08-07-2004, 04:00 AM   #3
flamesrock
Member
 
Registered: Aug 2003
Distribution: Gentoo 2006.1
Posts: 405

Original Poster
Rep: Reputation: 30
thankyou!
 
Old 08-07-2004, 07:55 PM   #4
flamesrock
Member
 
Registered: Aug 2003
Distribution: Gentoo 2006.1
Posts: 405

Original Poster
Rep: Reputation: 30
Ok, it works with one problem:

* * * * * reboot > /dev/null

>>>makes it restart every minute. If I want to change that to every hour or two hours, what line would I edit?

-thanks again
 
Old 08-07-2004, 09:25 PM   #5
louishp
LQ Newbie
 
Registered: Mar 2004
Posts: 13

Rep: Reputation: 0
the second one, so every hour you'd set the second field to 1,


The order is minutes hours days months weekdays commands

so

0 2 * * * /command

should do it i think
-Louis
 
  


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
My computer restart automatically from time to time ?? pleasehelpme Linux - Newbie 2 07-04-2005 04:29 PM
Automatically Restart Service tulip4heaven Linux - General 1 04-23-2005 02:11 AM
Way to automatically restart a program? AlexV Linux - General 1 04-13-2005 05:23 PM
Restart X server jbraum Linux - General 2 02-09-2004 01:01 PM
kernel automatically restart if there is a panic kernelpanicguy Linux - Software 3 07-29-2003 09:06 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration