Results 1 to 12 of 12
  1. #1

    * Need simple help in editing my cronjob

    Code:
    #!/bin/bash
    loadavg=`uptime | awk '{print $10}'`
    RESTART="/etc/init.d/httpd restart"
    thisloadavg=`echo $loadavg|awk -F \. '{print $1}'`
    if [ "$thisloadavg" -ge "400" ]; then
    echo "restarting due to load being $thisloadavg"
    $RESTART
    elif [ "$thisloadavg" -le "400" ]; then
    echo Not restarting, load is $thisloadavg
    if [ $? -ne 0 ]
    then
    $RESTART
    fi
    fi
    Guys the above are what I'm using now. Is it possible to make stop httpd and start again ONLY after certain timeframe like 15 minutes? Thanks for help

  2. #2
    Join Date
    Sep 2007
    Posts
    368

    *

    Quote Originally Posted by kohkindachi View Post
    Code:
    #!/bin/bash
    loadavg=`uptime | awk '{print $10}'`
    RESTART="/etc/init.d/httpd restart"
    thisloadavg=`echo $loadavg|awk -F \. '{print $1}'`
    if [ "$thisloadavg" -ge "400" ]; then
    echo "restarting due to load being $thisloadavg"
    $RESTART
    elif [ "$thisloadavg" -le "400" ]; then
    echo Not restarting, load is $thisloadavg
    if [ $? -ne 0 ]
    then
    $RESTART
    fi
    fi
    Guys the above are what I'm using now. Is it possible to make stop httpd and start again ONLY after certain timeframe like 15 minutes? Thanks for help

    ops 400 load, its better you optimize Apache and Mysql, its not good practice to restart Apache frequently.

    Regarding crontab. here is the way after every 15 minute whatever you want to do

    */15 * * * * root /your-script.sh

  3. #3
    the code you gave me is what I'm using now - run cronjob every 15mins. But read at the bold words of what i want

    Stop httpd and start again ONLY after certain timeframe like 15 minutes. What I've is RESTART

  4. #4
    Join Date
    Sep 2007
    Posts
    368

    *

    Quote Originally Posted by kohkindachi View Post
    the code you gave me is what I'm using now - run cronjob every 15mins. But read at the bold words of what i want

    Stop httpd and start again ONLY after certain timeframe like 15 minutes. What I've is RESTART
    I am sorry for that, you can setup your start like that, i have check it via cron it stop and restart

    Code:
    small script
    _________
    
    cat /allscripts/http.start
    
    /etc/init.d/httpd stop
    /etc/init.d/httpd start
    
    cron that i setup for testing
    ____________________
    
    */15  * * * * root /allscripts/http.start
    I think above is ok. If not please give some brief please. One thing I think its not possible you can only stop and start apache directly via cron

  5. #5
    Sorry if i'm wrong, does it stop and start every 15 mins? lol

  6. #6
    Join Date
    Sep 2007
    Posts
    368

    *

    Quote Originally Posted by kohkindachi View Post
    Sorry if i'm wrong, does it stop and start every 15 mins? lol

    Dear sir,

    You are asking question, and saying lol, i am not sure you are asking or telling by lol.

    Well regarding cron its working fine at my end, here is the detail,


    Code:
    httpd process is currently stop
    
    /etc/init.d/httpd status
    httpd is stopped
    
    httpd process is currently start after cron
    
    /etc/init.d/httpd status
    
    httpd (pid 6754 6753 6752 6751 6750 6749 6748 6747 6740) is running...
    
    
    apache logs, initially process already stop, it start it
    
    [notice] caught SIGTERM, shutting down
    [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    [notice] Digest: generating secret for digest authentication ...
    [notice] Digest: done
    [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
    [notice] Apache/2.2.3 (Red Hat) configured -- resuming normal operations
    
    
    apache logs when process is already start, it still stop and start apache.
    
    [notice] caught SIGTERM, shutting down
    [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    [notice] Digest: generating secret for digest authentication ...
    [notice] Digest: done
    [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
    [notice] Apache/2.2.3 (Red Hat) configured -- resuming normal operations

  7. #7
    I'm asking. Did it check or simple just 'stop and start' eveyy 15minutes?

    I assume if httpd is running, it'll not restart it and passed?

  8. #8
    Join Date
    Sep 2007
    Posts
    368

  9. #9
    Join Date
    Apr 2009
    Posts
    839
    check apache full status, this should help.

  10. #10
    Quote Originally Posted by nomankhn View Post
    Please dont assume, check your apache and cron logs
    lol just answer my question please

  11. #11
    Join Date
    Sep 2007
    Posts
    368

  12. #12
    Did it check or simple just 'stop and start' every 15minutes?

    I assume if httpd is running, it'll not restart it and passed? Yes or No

    Comprehension problem?
    Last edited by kohkindachi; 09-24-2009 at 10:02 PM.

Similar Threads

  1. Need simple Flash editing work done 5-10 minute job
    By youridol in forum Design Requests
    Replies: 2
    Last Post: 01-25-2008, 03:57 PM
  2. Cronjob Help
    By mohsinkhalid in forum Hosting Security and Technology
    Replies: 3
    Last Post: 09-18-2007, 12:57 AM
  3. cronjob
    By HD Fanatic in forum Hosting Security and Technology
    Replies: 5
    Last Post: 02-05-2007, 11:53 PM
  4. Need simple ASP code for cronjob
    By Ron in forum Programming Discussion
    Replies: 16
    Last Post: 05-21-2004, 08:48 AM

Posting Permissions

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