URGENT: Please help : start an application at boot time on linux automatically - Linux

This is a discussion on URGENT: Please help : start an application at boot time on linux automatically - Linux ; it is a news application which we start using the command "ant all" in linux as root. but what i really want to do is to check whether the application is already running and if not start it automatically....i think ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: URGENT: Please help : start an application at boot time on linux automatically

  1. URGENT: Please help : start an application at boot time on linux automatically

    it is a news application which we start using the command "ant all" in
    linux as root.

    but what i really want to do is to check whether the application is
    already running and if not start it automatically....i think it
    involves a crontab entry..also i want to start it automatically at
    boot.

    any help will be greatly appreciated.

    yours sincerely,

    down_to_planet.

  2. Re: URGENT: Please help : start an application at boot time on linux automatically

    Please read http://www.catb.org/~esr/faqs/smart-questions.html

    On 4 Sep 2003 12:52:08 -0700, indian wrote:
    > it is a news application which we start using the command "ant all" in
    > linux as root.
    >
    > but what i really want to do is to check whether the application is
    > already running and if not start it automatically....i think it
    > involves a crontab entry..


    Yes you can have a cron job to watch for a process that completely quits.

    You grep the output of ps for the process. If not there
    start it. Now if process just hangs but does not exit, then your
    script may not detect that.

    > also i want to start it automatically at boot.


    Depends on what distro. See code snippet for Redhat or Mandrake do a
    man chkconfig

    ------>8------>8------>8------>8------>8------>8------>8------>8
    #! /bin/bash
    #
    # log_ethx Log ip packets
    #
    # chkconfig: 2345 10 85
    # description: Logs ip bytes used on the ethx interface
    #
    #************************************************* *************************
    #*
    #* log_ethx - Log $GATEWAY rx/tx byte counts
    #*
    #* Usually called from from links in
    #* /etc/rc.d/rc6.d/K0Nlog_ethx
    #* /etc/rc.d/rc3.d/S0Nlog_ethx
    #* or
    #* service log_ethx {start|stop|reset|restart|status}
    #*
    #* Install:
    #* cp log_ethx /etc/rc.d/init.d
    #* chkconfig --add log_ethx
    #* service log_ethx start
    #*
    #************************************************* *************************

    .. /etc/init.d/functions # get action function
    .. /etc/sysconfig/network # get gateway device

    _exe=$0
    _arg1=$1

    _total_fn=/site/doc/${GATEWAYDEV}.total
    _date=`/bin/date "+%Y %m %d"`
    cd /etc/rc.d/init.d

    # See how we were called.
    case "$_arg1" in
    start)
    action "Starting =========> $GATEWAYDEV logging" echo " "
    touch /var/lock/subsys/log_ethx
    ;;
    status)
    gprintf "log_ethx\n"
    echo `cat $_total_fn`
    ;;
    stop)
    action "Stopping ===========> $GATEWAYDEV logging" echo " "
    set `/sbin/ifconfig $GATEWAYDEV` # pipe ifconfig into $args

    shift 30 # move 30 words left into bit bucket

    IFS=") " # set new word seperators

    set `echo $1 $2 $3 $4 $5 $6 $7 $8 $9` # reparse arguments for splitting

    if [ "$2" != "Interrupt" ] ; then # nic is in service
    echo "$_date $2 $3 $4 $5 $7 $8 $9" >> $_total_fn # save them
    fi

    /bin/chmod 666 $_total_fn
    rm -f /var/lock/subsys/log_ethx
    ;;
    reset)
    action "Resetting $GATEWAYDEV logging" echo " "
    /bin/cp /dev/null $_total_fn
    /bin/chmod 666 $_total_fn
    ;;
    restart|reload)
    cd $CWD
    $_exe stop
    $_exe start
    ;;
    *)
    gprintf "Usage: %s {start|stop|reset|restart|status} not $_arg1\n" $0
    exit 1
    esac

    exit 0

    #******************* end log_ethx ****************************************
    ------>8------>8------>8------>8------>8------>8------>8------>8

+ Reply to Thread