Sponsored Content
Top Forums Shell Programming and Scripting Help scripting to start, check, and restart processes Post 302533367 by MacG32 on Thursday 23rd of June 2011 12:15:10 PM
Old 06-23-2011
In my case, the -r only produces 1 additional chkscreen and java-daemon.sh process, and only 1 Java server process. When I changed the -r to -S, it kept making chkscreen and java-daemon.sh processes and no additional Java server processes. That's why I was trying to get and use the PIDs, using the second script in the OP.

If Java uses all of the machine's memory, then the screen will be terminated. I'll no longer be attached to it, so the check for being or not being attached may not be the approach needed. I'll try and use what you've kindly given me and integrate something to get and check the PIDs.

No need to be sorry and lose sleep over this. It'll get worked out eventually and I'll post the final tweaked results then. Below is what I'm using. Thanks a million for all of your help neutronscott.

chkscr
Code:
#!/bin/sh
# chkscr: checks if a screen session is running.

SESSION="server1"
DAEMON="screen -d -m -S $SESSION /home/*server*/*local*/jd.sh"

# does the session exist?
screen -r $SESSION -ls -q 2>&1 >/dev/null

if [ $? -le 10 ]; then
        echo "Restarting $DAEMON"
        $DAEMON
fi

jd.sh
Code:
#!/bin/sh
# jd.sh: restarts a stopped server.

while true; do
java *server variables*
wait
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can I make a program start up automatically after the computer restart/startup?

hi all How can I make a program start up automatically after the computer restart/startup in fedora? something like: ... Establish a shell then run some of command code. Thanks for Help!! (1 Reply)
Discussion started by: munna_dude
1 Replies

2. Shell Programming and Scripting

need help: shell script to restart apache when no. of processes keeps growing

I need a shell script to kill apache and restart it, in case the number of processes keeps growing. The logic is like the below, but I don't know how to get the number and neither the syntax. Could somebody kindly help? if no_of_processes (ps ax ¦ grep httpd) > 200 then killall httpd... (14 Replies)
Discussion started by: _joshua_
14 Replies

3. AIX

How to start/stop/restart NFS on AIX

Hi, Very new to aix How to start/stop/restart NFS on AIX thanks, (2 Replies)
Discussion started by: jredx
2 Replies

4. UNIX for Advanced & Expert Users

Log 'syslog start/stop/restart' messages

How can I tell my syslog.conf to log "syslog start/stop/restart" messages on a Solaris box? (1 Reply)
Discussion started by: SunnyK
1 Replies

5. Shell Programming and Scripting

Start Stop Restart

I'm wondering how I should make a script that can start, stop, and restart another script. What I need to be able to do, is start and stop a perl script from the command line. The easiest way of doing this seems to be to have another script, starting and stopping the other script. I have BASH,... (7 Replies)
Discussion started by: Bakes
7 Replies

6. Shell Programming and Scripting

guarantee to start before restart...

Hi All, is there a way or script that i can check my AIX 5.3 OS will restart before i made restart? is there a script that can check all the startup files are ok before restarting. it is because i was stuck last time when i restart my PC because some startup files were missing:o. (2 Replies)
Discussion started by: malcomex999
2 Replies

7. Solaris

How to start/stop processes

Please anyone tell me In my last interview the HR asks me how to monitor, start,stop & kill the various processes and subprocesses. Please anyone explain me clearly. It's my personal request (3 Replies)
Discussion started by: suneelieg
3 Replies

8. UNIX for Dummies Questions & Answers

Stop/Start vs. Restart

Is there any functional difference between: issuing separate stop/start commands like this; super (handler) (instance) stop super (handler) (instance) start versus issuing a single recycle command like this; super (handler) (instance) restart (3 Replies)
Discussion started by: Newbix
3 Replies

9. Emergency UNIX and Linux Support

Check hung process and restart

Hi all I have networker running on a RHEL 5.7 and over time it hangs. So the solution backup team proposed is to check if the process is hung, to stop and start it. Unfortunately for me, the rc script only allows three commands, start, stop and status (no restart option) so I managed to set... (15 Replies)
Discussion started by: hedkandi
15 Replies

10. Red Hat

Service restart and check if running

Hello, I'l like to create a script that restart a service (/etc/init.d/httpd restart) and also check if after restart the service is actually running. Sometimes it happen that at the first try the service fails to restart. Thanks (2 Replies)
Discussion started by: bazzola
2 Replies
JSVC(1) 						   Apache Commons Daemon project						   JSVC(1)

NAME
jsvc - application to launch java daemon SYNOPSIS
jsvc [-jvm JVM name] [-client client JVM] [-server server JVM] [-classpath path] [-cp path] [-java-home directory] [-version] [-help] [-?] [-nodetach] [-debug] [-check] [-user user] [-wait waittime] [-umask mask] [-stop] [-verbose:class|gc|jni] [-outfile /full/path/to/file] [-errfile /full/path/to/file] [-pidfile /full/path/to/file] [-Dproperty=value] [-Xoption] DESCRIPTION
jsvc executes classfile that implements a Daemon interface. OPTIONS
-jvm JVM name use a specific Java Virtual Machine. -client client JVM use a client Java Virtual Machine. -server server JVM use a server Java Virtual Machine. -cp/ -classpath directory and zip/jar files set search path for service classes and resouces -java-home directory set the path of your JDK or JRE installation (or set the JAVA_HOME environment variable) -version show the current Java environment version (to check correctness of -home and -jvm. Implies -nodetach) -help show this help page (implies -nodetach) -nodetach don't detach from parent process and become a daemon -debug verbosely print debugging information -check only check service (implies -nodetach) -stop stop the service using the file given in the -pidfile option -wait waittime wait up to waittime seconds for the service to start waittime should multiple of 10 (min=10) -umask mask sets the file mode creation mask -user user user used to run the daemon (defaults to current user) -verbose[:class|gc|jni] enable verbose output -outfile /full/path/to/file Location for output from stdout (defaults to /dev/null). Use the value '&2' to simulate '1>&2', or 'SYSLOG' to send output to the system log. -errfile /full/path/to/file Location for output from stderr (defaults to /dev/null). Use the value '&1' to simulate '2>&1', or 'SYSLOG' to send output to the system log. -pidfile /full/path/to/file Location for output from the file containing the pid of jsvc (defaults to /var/run/jsvc.pid) -D<name>=<value> set a Java system property -X<option> set Virtual Machine specific option AUTHOR
JSVC is part of the Apache Commons Daemon project. Authors are Jean-Frederic Clere, Remy Maucherat, Yoav Shapira, Bill Barker, Mladen Turk. JSVC is released under the Apache License Version 2.0. Jsvc version 1.0.6 08/17/2012 JSVC(1)
All times are GMT -4. The time now is 03:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy