Find the answer to your Linux question:
Results 1 to 4 of 4
Hey, I am stuck a little bit with the following problem: My web server is running stable for most of the time. Although it happens that occasionally it is no ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2012
    Posts
    18

    Reboot a server automatically if it runs out of resources


    Hey,

    I am stuck a little bit with the following problem:

    My web server is running stable for most of the time. Although it happens that occasionally it is no longer reachable via SSH and Apache is not available neither.

    My theory is that the server is running out of resources in such situations and the ssh and apache demon are killed by the kernel.

    A reboot fixes the issue.

    I am wondering if there is a way to reboot my server automatically in case that event happens (for example it is no longer available via ssh) in order to avoid downtimes.

    Thanks a lot!!

    Cheers

  2. #2
    Linux Newbie arespi's Avatar
    Join Date
    May 2011
    Location
    Monterrey , Mexico
    Posts
    135
    Hi, just an idea:

    You could make a small bash script that checks for the ssh and apache services status and put it in your servers crontab , and upon their results launch the reboot. If your server freezes beyond some services down, like a kernel panic or something like that this may not work.

    Good luck

  3. #3
    Just Joined!
    Join Date
    Aug 2007
    Location
    Fairfax, VA
    Posts
    22
    No offense but that is not the linux way! If it crashes and hangs, there *must* be a reason! Can you log on locally? Anything in the logs? There is a utility called kdump to catch kernel crashes. Sorry I've had a few drinks, but I'd highly suggest trying to figure out what the issue is, linux doesn't just run out of resources and hang, this isn't windows.

  4. #4
    Linux Engineer
    Join Date
    Apr 2012
    Location
    Virginia, USA
    Posts
    881
    There is no reliable way to do this. If the server is so overloaded that it hangs, then your script is not going to execute either. What you need to do is figure out what's crashing your server, and fix it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •