Cron Job $5

Discussion in 'Services' started by circuscircus, Feb 13, 2007.

Thread Status:
Not open for further replies.
  1. #1
    I need a cron job that reboots the server every 1 hour between 6:AM till 3PM

    and reboots every 3 hours the rest of the time

    PM Me -- I will have you VNC to my computer to set it up on SSH for me
     
    circuscircus, Feb 13, 2007 IP
  2. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    Are your proxies getting stuck :D
     
    login, Feb 13, 2007 IP
  3. circuscircus

    circuscircus Peon

    Messages:
    240
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    Lol yea the RAM is maxing out and crashes occasionally which gets me pretty mad :confused: cuz then my adsense is like at a halt
     
    circuscircus, Feb 14, 2007 IP
  4. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    I had the same problem, but I didnt use a cron job. I had it on a VPS, but didnt remember how I did it. There are file where you can change to make this happen. Sorry I cant help you more. It was pretty easy though.
     
    login, Feb 14, 2007 IP
  5. tanfwc

    tanfwc Peon

    Messages:
    579
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    Have you try to tweak Apache and find out the root cause of the problem? Rebooting is not a long term solution
     
    tanfwc, Feb 14, 2007 IP
  6. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    There must be a way of limiting requests. To many requests are the problem right? or is it that some of the proxy users are just leechers from megaupload and so on? In that case you can block that site.
     
    login, Feb 14, 2007 IP
  7. circuscircus

    circuscircus Peon

    Messages:
    240
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #7
    It's not the bandwidth...so i dont think preventing leachers will help much

    its those session encryptions n stuff IMO

    does anyone know get this fixed? Cuz Im tired of rebooting 5 times a day
     
    circuscircus, Feb 14, 2007 IP
  8. rondhro

    rondhro Banned

    Messages:
    45
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #8
    I have a load balancing shell programm for linux server, manually made by me. It works great for cpanel proxy servers. But the fact is, it doesn't have any automated installaton. If you are interested to take it, then i need to configure it in your server. Please PM me regarding this.
     
    rondhro, Feb 14, 2007 IP
  9. mikkom

    mikkom Active Member

    Messages:
    266
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #9
    That sounds crazy!

    Anyway it's quite easy, just create a job that says:

    
    #! /bin/sh
    reboot
    
    Code (markup):
    Save it to some file, put chmod +x to the file and add it to your crontab to match every hour you wish (it's worth the time to learn crontab syntax, it's basically a matcher for certain times when to call your script)

    Crontab will basically look something like:
    
    1 6    * * *   root    path/reboot-script.sh
    1 7    * * *   root    path/reboot-script.sh
    1 8    * * *   root    path/reboot-script.sh
    ...
    
    Code (markup):
    Hope this helps, I don't even need the $5 :D
     
    mikkom, Feb 16, 2007 IP
  10. andre75

    andre75 Peon

    Messages:
    1,203
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #10
    I usually use
    shutdown -r now
    or
    shutdown -f -r now (f = force)

    The crontab should look something like this though:
    0 */1 * * * path/reboot-script.sh
    to reboot every hour at xx:00
    I don't see the owner in my crontab

    If I were you I would switch webservers (either to lighttpd or something even smaller) and I would monitor those processes. Especially for proxies those should work way better, since you can push a lot more connections on those without eating up your ram.
    You could easily restart apache
    0 */1 * * * /etc/apache2 force-restart

    Or you could monitor memory usage with a little script.
    Overall you should manage your server right. There is no need to force a restart. Apache doesn't have any memory leaks (at least not to my knowlegde) so I figure that your processes either stay as zombies or that your simply allow too many apache processes
    (check /etc/apache2/httpd.conf and /etc/apache2/apache2.conf) and google around to find out how to configure it right
     
    andre75, Feb 16, 2007 IP
  11. mikkom

    mikkom Active Member

    Messages:
    266
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #11
    That's true if you want to reboot every hour but see the original question ;) That was not what he was asking for..

    And I totally agree with you that this shouldn't be done anyway. Rebooting the server is not the answer to whatever problem actually is (unless of course you are using a windows box eh) :D
     
    mikkom, Feb 17, 2007 IP
  12. andre75

    andre75 Peon

    Messages:
    1,203
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #12
    0 */3 * * * path/reboot-script.sh
    0 7 * * * path/reboot-script.sh
    0 8 * * * path/reboot-script.sh
    0 10 * * * path/reboot-script.sh
    ...

    will still end up in less lines. The first line takes care of the reboot every 3 hours and the other lines fill in the gaps.
     
    andre75, Feb 17, 2007 IP
Thread Status:
Not open for further replies.