Results 1 to 10 of 10
  1. #1
    Join Date
    Oct 2004
    Posts
    76

    Auto Restart a service every "X" amount of minutes

    Currently, with the way my server is setup it runs pretty well, but one of my major services likes to hang if its up to long w/o a restart. I currently have something to restart it every so often to avoid this problem, but it runs on my computer. However, what im wondering is if theres anything server side that can do this? Maybe a cron job?


    Thanks.


    Its apache that likes to hang. I know why it hangs because my maxclients is set low. However, it must stay like this so i wont go over my VPS specs so much. Its been working perfectly with firefox autoreloadpage script. If my internet goes down than nothing will be able to autoreload the service. Thats why i need a cron job i believe.

    If anyone would kind enough to write out the exact line i would add to a cron job. l'll be very thankful.

    Thanks
    GottaDeal.com - Hot Deals & Coupon Codes. Why Pay Retail?http://www.gottadeal.com/images/bann...eal-234x60.gif

  2. #2
    Join Date
    Apr 2004
    Location
    Singapore
    Posts
    1,506
    check out this software.

    http://rfxnetworks.com/sim.php
    tanfwc
    Singapore Managed Colocation
    Singapore BGP Announcement

  3. #3
    Yep, or for the cron job:

    service httpd restart

    would do the trick in most configurations.

    The cron job would have to be for the root user though, not put in Cpanel or anything like that.

  4. #4
    Join Date
    Jun 2003
    Location
    Janesville, Wi
    Posts
    1,516
    tanfwc's solution is good for automated crashes, tho it might not catch everything. So a mix of both SIM and crontab (mentioned by stephanhughson) might be a good idea.

    In case you don't know about how cron works, here's how:

    In SSH, execute:

    crontab -e

    Type "o" to open a new line. The format of the job for a every X minute restart is:

    [min] [hour] * * * /sbin/service httpd restart

    So if you wanted it two restart twice an hour (every 30 minutes)

    */2 * * * * /sbin/service httpd restart

    Once an hour at the top of the hour:

    0 * * * * /sbin/service httpd restart

    Daily at 3:25AM:

    25 3 * * * /sbin/service httpd restart

    You get the idea.

    To save, type: Esc followed by Shift+ZZ
    Jakiao

  5. #5
    Join Date
    Oct 2004
    Posts
    76
    Quote Originally Posted by stephanhughson
    Yep, or for the cron job:

    service httpd restart

    would do the trick in most configurations.

    The cron job would have to be for the root user though, not put in Cpanel or anything like that.

    works perfect in webmin Thank you!
    GottaDeal.com - Hot Deals & Coupon Codes. Why Pay Retail?http://www.gottadeal.com/images/bann...eal-234x60.gif

  6. #6
    Join Date
    Dec 2004
    Location
    Spain
    Posts
    126
    You might prefer to use the "graceful" restart for the apache daemon - see http://httpd.apache.org/docs/2.0/stopping.html (or search for a similar page if you are still running an apache 1 series)

  7. #7
    Join Date
    Oct 2004
    Posts
    76
    Sorry, didn't see the other replies. The other things might work also, it seems the service restart is alittle easier to do with the plain cron.

    apachectl -k restart does seem alittle better, but if i run into problems with the restart http cron than ill look @ the graceful one.


    Thanks for the other soultions though. ;]
    GottaDeal.com - Hot Deals & Coupon Codes. Why Pay Retail?http://www.gottadeal.com/images/bann...eal-234x60.gif

  8. #8
    Join Date
    May 2005
    Location
    Portland, OR
    Posts
    28
    A cron is just a band-aid. You need a solution that will actual fix the root cause. If that means more tuning so you can increase maxclients and still stay in your VPS allocation, that's what really needs to be done. Or, you need to expand out and buy a larger VPS

  9. #9
    Some very nice mini-tutorials from everyone here :-) Apart from mine, which was a bit brief in comparison :-(

    I guess you are using Cpanel and will be needing to stick with Apache really, to avoid breaking/messing with Cpanel, which is never good...

    What you could do though, is install something like:

    thttpd
    or
    lighttpd

    Those are two web server packages that are very efficient.

    What's I've seen in the past, is for people to have their main websites running on their main IP address, then a second web server server running on a secondary IP address. This can be useful in some situations, but it just depends what you need really.

    Or another option as I mentioned in another post would be to have a reverse proxy server, but that's going to take quite a bit of messing about. Ugrading the VPS is probably best when you can afford it/have to.

  10. #10
    Join Date
    Oct 2004
    Posts
    76
    ^^^ I run webmin. But i can't afford to get lighthttp installed. Most installer quote either $50 or $100 to install. Ill just stick with apache for the time being.
    GottaDeal.com - Hot Deals & Coupon Codes. Why Pay Retail?http://www.gottadeal.com/images/bann...eal-234x60.gif

Posting Permissions

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