Find the answer to your Linux question:
Results 1 to 8 of 8
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Application monitoring


    The requirement is to monitor an application which should be executing all the time, and if the application is down for any reason, it should be automatically started by the monitoring script.
    For this, currently we have written a monitoring script which is added to a crontab and it is scheduled for execution every minute. This(monitoring script) should start the application if it is down. Currently it is not working as expected for some reason. We have a command in the script which uses 'nohup' to bring up the application, this command is working fine when issued thru the command prompt, but not working when it is used in the shell script.
    I need help in finding out what the issue could be with the shell script and also if there is an alternate method to achieve the objective stated.

    Thanks in advance.

  2. #2

    without the scripts, we'll just have to guess.
    it may take a very long time, until we hit it right !

    as crontab does not have tty, nohup is useless.
    check path for every command is in PATH.
    if an application can be down, it should be started from inittab.

  3. #3

    Below is the script contents.

    # check daemon
    ps -ef | grep -v grep | grep comon.App
    # if not found - equals to 1, start it
    if [ $? -eq 1 ]
    nohup   /app/Oracle/Middleware/jdk160_21/bin/java -cp /app/abcd/watch/LogS.jar logs.comon.App &
    echo " already running - do nothing"
    If the following code is executed manually the application starts...
    nohup   /app/Oracle/Middleware/jdk160_21/bin/java -cp /app/abcd/watch/LogS.jar logs.comon.App &
    So not sure what the issue is.

  4. $spacer_open
  5. #4
    Hello and welcome to LinuxForums!

    I would use screen to to do this, instead of nohup.

    It will launch a screen session in the background, with your named process running in the foreground of that screen. Here's an example of how to call it:

    screen -dm -S Java_App /app/Oracle/Middleware/jdk160_21/bin/java -cp /app/abcd/watch/LogS.jar logs.comon.App
    To list running screens for a given user, do:
    screen -ls
    to attach to the pid of a screen (returned by the above command):
    screen -r <PID>
    or in the above case, you can use the screen name like:
    screen -r Java_App
    if you need to clean screens:
    screen -wipe
    Also, to trouble-shoot your original issue, i would add logging to the cronjob, e.g.:
    10 0 * * * /path/to/ > /tmp/script-cronjob.log 2>&1
    then check that log file for errors that you might normally not be seeing, when cron runs the job.

  6. #5
    better is to not use ps, because it shows itself too.
    instead use pidof, or pgrep.

  7. #6
    Can this be implemented in a production environment ?

  8. #7
    Quote Originally Posted by bornon2303 View Post
    Can this be implemented in a production environment ?
    I'm not sure why not. It is not much different from your nohup method.

    Before pushing anything into production, though, I would be testing it out the wazoo on a system that is hopefully identical in hardware and software under a similar load.

  9. #8
    Is this method and software for application monitoring is similar to credit card monitoring? I am baffled, please do help. Thanks.

Posting Permissions

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