Find the answer to your Linux question:
Results 1 to 7 of 7
So I have Red HAT ES3 and I am setting up to run JSPs. I have tomcat, jdk, mysql, blah blah balh installed. My question is how to have the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2004
    Location
    MO, USA
    Posts
    34

    a couple Red Hat ES3 questions


    So I have Red HAT ES3 and I am setting up to run JSPs. I have tomcat, jdk, mysql, blah blah balh installed. My question is how to have the programs start up when the server starts? Also, how do I dictate what user each program is started up by?

  2. #2
    Just Joined!
    Join Date
    Dec 2004
    Posts
    14
    Following is the init(start/stop) script for tomcat. Create and save as "tomcatd" in /etc/rc.d/init.d
    Code:
    # This is the init script for starting up the
    #               Jakarta Tomcat server
    #
    # chkconfig: 345 91 10
    # description: Starts and stops the Tomcat daemon.
    #
    
    # Source function library.
    . /etc/rc.d/init.d/functions
    
    # Get config.
    . /etc/sysconfig/network
    
    # Check that networking is up.
    [ "${NETWORKING}" = "no" ] && exit 0
    
    #Path to tomcat home
    tomcat=/usr/java/tomcat 
    startup=$tomcat/bin/startup.sh
    shutdown=$tomcat/bin/shutdown.sh
    export JAVA_HOME=/usr/java/jdk1.5.0
    
    start(){
            echo -n $"Starting Tomcat service: "
            #daemon -c
            $startup
            RETVAL=$?
            echo
    }
    
    stop(){
            action $"Stopping Tomcat service: " $shutdown
            RETVAL=$?
            echo
    }
    
    restart(){
        stop
        start
    }
    
    
    # See how we were called.
    case "$1" in
      start)
            start
            ;;
      stop)
            stop
            ;;
      status)
            # This doesn't work ;)
            status tomcat
            ;;
      restart)
            restart
            ;;
      *)
            echo $"Usage: $0 {start|stop|status|restart}"
            exit 1
    esac
    
    exit 0
    After which, execute the following command in /etc/rc.d/init.d

    #chkconfig --add tomcatd
    #chkconfig --level 35 tomcatd on

  3. #3
    Just Joined!
    Join Date
    Dec 2004
    Posts
    14
    Following is the init(start/stop) script for MySQL. Create and save as mysqld in /etc/rc.d/init.d:

    Code:
    # MySQL daemon start/stop script.
    # chkconfig: - 78 12
    # description:  MySQL database server.
    # processname: mysqld
    # config: /etc/my.cnf
    # pidfile: /var/run/mysqld/mysqld.pid
    #
    
    
    prog="MySQL"
    
    rundir="/var/run/mysqld"
    basedir=
    
    # Check to see if run directory exists, if not create it
    
    if [ ! -d $rundir ]; then
       mkdir $rundir
       chown mysql.mysql $rundir
    fi
    
    
    # The following variables are only set for letting mysql.server find things.
    
    # Set some defaults
    datadir=/var/lib/mysql
    pid_file=
    if test -z "$basedir"
    then
      basedir=/
      bindir=/usr/bin
    else
      bindir="$basedir/bin"
    fi
    
    PATH=/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin
    export PATH
    
    mode=$1    # start or stop
    
    parse_arguments() {
      for arg do
        case "$arg" in
          --basedir=*)  basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
          --datadir=*)  datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
          --pid-file=*) pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
        esac
      done
    }
    
    # Get arguments from the my.cnf file,
    # groups [mysqld] [mysql_server] and [mysql.server]
    
    if test -x ./bin/my_print_defaults
    then
      print_defaults="./bin/my_print_defaults"
    elif test -x $bindir/my_print_defaults
    then
      print_defaults="$bindir/my_print_defaults"
    elif test -x $bindir/mysql_print_defaults
    then
      print_defaults="$bindir/mysql_print_defaults"
    else
    
      # Try to find basedir in /etc/my.cnf
      conf=/etc/my.cnf
      print_defaults=
      if test -r $conf
      then
        subpat='^[^=]*basedir[^=]*=\(.*\)$'
        dirs=`sed -e "/$subpat/!d" -e 's//\1/' $conf`
        for d in $dirs
        do
          d=`echo $d | sed -e 's/[  ]//g'`
          if test -x "$d/bin/my_print_defaults"
          then
            print_defaults="$d/bin/my_print_defaults"
            break
          fi
          if test -x "$d/bin/mysql_print_defaults"
          then
            print_defaults="$d/bin/mysql_print_defaults"
            break
          fi
        done
      fi
    
    
      # Hope it's in the PATH ... but I doubt it
      test -z "$print_defaults" && print_defaults="my_print_defaults"
    fi
    
    #
    # Test if someone changed datadir;  In this case we should also read the
    # default arguments from this directory
    #
    
    extra_args=""
    if test "$datadir" != "/var/lib/mysql"
    then
      extra_args="-e $datadir/my.cnf"
    fi
    
    parse_arguments `$print_defaults $extra_args mysqld mysql_server mysql.server`
    
    #
    # Set pid file if not given
    #
    if test -z "$pid_file"
    then
      pid_file="/var/run/mysqld/mysqld.pid"
    else
      case "$pid_file" in
        /* ) ;;
        * )  pid_file="/var/run/mysqld/mysqld.pid" ;;
      esac
    fi
    
    # Safeguard (relative paths, core dumps..)
    cd $basedir
    
    case "$mode" in
      'start')
        # Start daemon
            touch /var/log/mysql/mysqld.log
            chown mysql.mysql /var/log/mysql/mysqld.log
            chmod 0640 /var/log/mysql/mysqld.log
    
        # Check to see if datadir exists, if not initialize database
    
            if [ ! -d $datadir ] ; then
                echo "Initializing MySQL database: "
                /usr/bin/mysql_install_db
            # Give a few seconds for mysql to start
                chown -R mysql.mysql $datadir
                echo "Please wait whilst initialization completes"
                sleep 5
            fi
    
            chown -R mysql.mysql $datadir
            chmod 0755 $datadir
    
    # Check to see if MySQL is running already
    
    if test -s "$pid_file"
        then
          echo "$prog appears to be already running, or was shutdown uncleanly. If this is the case remove the file:
    '$pid_file', and start again"
    
    else
        if test -x $bindir/mysqld_safe
        then
          # Give extra arguments to mysqld with the my.cnf file. This script may
          # be overwritten at next upgrade.
          $bindir/mysqld_safe --datadir=$datadir --pid-file=$pid_file >/dev/null 2>&1 &
          # Make lock for RedHat / SuSE
          if test -w /var/lock/subsys
          then
            touch /var/lock/subsys/mysql
          fi
            echo $"Starting $prog: "
            # Give a few seconds for mysql to start completely
            echo "Please wait whilst $prog completes"
            sleep 5
        else
          echo "Can't execute $bindir/mysqld_safe from dir $basedir"
        fi
    fi
        ;;
    
      'stop')
        # Stop daemon. We use a signal here to avoid having to know the
        # root password.
    
        if test -s "$pid_file"
        then
          mysqld_pid=`cat $pid_file`
          echo "Stopping $prog: "
          kill $mysqld_pid
          # mysqld should remove the pid_file when it exits, so wait for it.
    
          echo "Waiting for $prog to shutdown"
          sleep 10
          if [ -s $pid_file ]
             then echo "Forcing removal of pid file"
             rm -rf $pid_file
          elif [ -n "$flags" ]
             then echo " done"
          fi
          # delete lock for RedHat / SuSE
          if test -f /var/lock/subsys/mysql
          then
            rm -f /var/lock/subsys/mysql
          fi
        else
          echo "$prog does not appear to be running!!!"
        fi
        ;;
    
      'restart')
        # Stop the service and regardless of whether it was
        # running or not, start it again.
        $0 stop
        $0 start
                    ;;
    
      *)
        # usage
        echo "Usage: $0 start|stop|restart"
        exit 1
        ;;
    esac
    After which, execute the following command in /etc/rc.d/init.d
    #chkconfig --add mysqld
    #chkconfig --level 35 mysqld

  4. #4
    Just Joined!
    Join Date
    Jul 2004
    Location
    MO, USA
    Posts
    34
    wow thanks, but what user is it running as on those programs?

  5. #5
    Just Joined!
    Join Date
    Jul 2004
    Location
    MO, USA
    Posts
    34
    the tomcat one didnt work.

  6. #6
    Just Joined!
    Join Date
    May 2005
    Posts
    97
    did you update the tomcat file at all?

    you have to update it as per your system, folders and what not can vary.

    read the script and change any pertinant info (folders)

    Luma

  7. #7
    Just Joined!
    Join Date
    Jul 2004
    Location
    MO, USA
    Posts
    34
    I did that, i changed the paths to tomcat and such, still didnt work.

Posting Permissions

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