Results 1 to 4 of 4

Thread: Need BIND, apache restart script

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default Need BIND, apache restart script

    Hi,

    I am working on Centos 5.2 32 bit VPS. BIND9

    On my server, BIND does restart automatically generally once in a month. Apache restarts automatically generally once a week. Is there any script which will execute automatically to start BIND or Apache process if BIND / Apache doesn't starts in such events.

    Thanks.

  2. #2
    Never say die nixcraft's Avatar
    Join Date
    Jan 2005
    Location
    BIOS
    Posts
    4,513
    Thanks
    17
    Thanked 804 Times in 511 Posts
    Rep Power
    10

    Default

    Just call your init.d script from crontab. No need to write anything from scratch.
    All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]


  3. #3
    Junior Member
    Join Date
    Feb 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Hi,

    I have tried to use below script

    #!/bin/bash
    # Apache Process Monitor
    # Restart Apache Web Server When It Goes Down
    # -------------------------------------------------------------------------
    # Copyright (c) 2003 nixCraft project <http: //cyberciti. biz/fb/>
    # This script is licensed under GNU GPL version 2.0 or above
    # -------------------------------------------------------------------------
    # This script is part of nixCraft shell script collection (NSSC)
    # Visit http: //bash.cyberciti. biz/ for more information.
    # -------------------------------------------------------------------------
    # RHEL / CentOS / Fedora Linux restart command
    RESTART="/etc/init.d/httpd restart"


    #path to pgrep command
    PGREP="ps -e | grep httpd"

    # Httpd daemon name,
    # Under RHEL/CentOS/Fedora it is httpd
    # Under Debian 4.x it is apache2
    HTTPD="httpd"

    # find httpd pid
    $PGREP ${HTTPD}

    if [ $? -ne 0 ] # if apache not running
    then
    # restart apache
    $RESTART
    fi
    crontab -e

    */1 * * * * /etc/apache.sh >/dev/null 2>&1

    And checked apache will restart after 1 min after stopping it.
    It is not starting.
    Also, I have tried with RESTART="service httpd restart"
    it also not working.

    Command /usr/bin/pgrep is showing below output, so I have changed it in the script.

    /usr/bin/pgrep
    pgrep: No matching criteria specified
    Usage: pgrep [-flvx] [-d DELIM] [-n|-o] [-P PPIDLIST] [-g PGRPLIST] [-s SIDLIST]
    [-u EUIDLIST] [-U UIDLIST] [-G GIDLIST] [-t TERMLIST] [PATTERN]


    Please help.

    Thanks.
    Last edited by ckinikar; 27th February 2013 at 03:27 PM.

  4. #4
    Junior Member
    Join Date
    Feb 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Someone, please reply, please help.
    Thanks.
    Last edited by ckinikar; 4th March 2013 at 06:33 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Restart apache if goes in timeout
    By vampire in forum CentOS / RHEL / Fedora
    Replies: 5
    Last Post: 31st May 2011, 02:39 PM
  2. Perl Issue when restart Apache
    By raveesh.pra in forum Web servers
    Replies: 1
    Last Post: 4th August 2010, 02:21 PM
  3. [Solved] Redhat restart Apache
    By chiku in forum CentOS / RHEL / Fedora
    Replies: 7
    Last Post: 28th September 2009, 07:56 PM
  4. how to restart apache when die.
    By LifeTimes in forum CentOS / RHEL / Fedora
    Replies: 2
    Last Post: 13th May 2008, 06:03 PM
  5. Linux command to restart apache
    By chiku in forum Linux software
    Replies: 2
    Last Post: 13th December 2006, 06:59 PM

Tags for this Thread

Posting Permissions

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