Check status of process


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Check status of process
# 1  
Old 05-28-2019
Check status of process

Hi All,
Have a query
How to check for a process and if down start it , try if for 2 times and its not starting don't do it
My code is working to some extent but while starting try starting both times.

Please advise , whats wrong here ?
if you have any other approach please do share.

My code
Code:
#!/bin/bash


file="/root/jboss.txt"
if [ -f "$file" ]
   then
   Exit 1
                else
		 
               
                A=$(ps -ef | grep 'jboss' | grep -v 'grep' | awk '{ printf $2 }')
                echo $A
                    if [ -z "$A" ]; then
                       
                                 starting jboss
                                if [ $? -eq 0 ]; then
                                   
                                else
                                   
								fi
                                  #starting jboss 2nd time
                                  starting jboss 
                                if [ $? -eq 0 ]; then
                                   echo "startted
                                else
                                   echo "Failed"
                                   touch jboss.txt
                                fi
                    else
                    echo "jboss is RUNNING"
                    fi
fi

Thanks
abhaydas

Last edited by Scrutinizer; 05-28-2019 at 07:47 AM.. Reason: Code tags instead of quote tags
# 2  
Old 05-28-2019
Please explain what you mean by:

Quote:
My code is working to some extent but while starting try starting both times.
Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to check process status

Hi Team, I am using redhat 6.4 version server.We have a script which is used to check the process and sends email if the process is not running.If it is running it will continue and do some other operation. I didnot understand below option -z in the if condition.I have tried to... (5 Replies)
Discussion started by: muraliinfy04
5 Replies

2. Shell Programming and Scripting

Check HD status

I have some server ( IBM , Dell ) , our data center is not in the same location with office , therefore , I do not know if the HD lamp is flash when the HD is fault , can advise if I can write a script to check if the HD is normal running or not ? thanks (1 Reply)
Discussion started by: ust
1 Replies

3. Shell Programming and Scripting

How to check the process status

Hi, I have a cron job which runs every ten minutes, now i hav to check the process whether it is running or not only once and then this should be sent to a log file.. crontab : 00,10,20,30,40,50 * * * * a process check ps = 'ps -ef |grep a ' if then echo " Success" >... (3 Replies)
Discussion started by: NehaKrish
3 Replies

4. Shell Programming and Scripting

How to Check the process Status and do something

Hi we have weblogic deployed under Linux Enterprise 5 . Now i want to write a script that checks if weblogic is running or not I have found that weblogic uses Java as process . Can i do this way : my Script File : Echo Checking Status if then echo Server Running else echo... (2 Replies)
Discussion started by: Ravi Pavanv
2 Replies

5. Shell Programming and Scripting

Check process running Status with PID

Good day I am fairly new to Shell Scripting. I want a script to check if a process is up by checking the process's PID and then return a value for when it's running which would be 0. If it isn't running it should give any other value that 0. Any Help is appreciated Regards (9 Replies)
Discussion started by: 1nsyz1on
9 Replies

6. AIX

check the status of ypbind

hello , How do i to check the status of ypbind on AIX(5.3) platform ? Thanks AVK Linux (1 Reply)
Discussion started by: avklinux
1 Replies

7. Shell Programming and Scripting

Check FTP Status

To all, I need to run a ftp command in one of my scripts and I need to evaluate what happens after it's done. The problem is the script would not capture the ftp responses. If I type the same thing on the command line, I get all kinds of responses. I would like to capture the same responses in... (2 Replies)
Discussion started by: april
2 Replies

8. Programming

process status

hello everybody!! i want to post a question! is there any way to get process status using C commands? To be more specific, i want to know whether a process is running or is stop or killed. thanks in advance! (3 Replies)
Discussion started by: nicos
3 Replies

9. Shell Programming and Scripting

Pls Help me out ... I want to check process status at regular intervals of time

I want to check process status at regular interval of time ... so i ha wirtten this BUT its not working when i placed this peace of code in .sh .. please help me out #!/bin/sh w = ps -ef|grep processname | wc - l echo $w if ; then Banner "Proceesname Problem" else Banner " Running... (5 Replies)
Discussion started by: srinivasvandana
5 Replies

10. Shell Programming and Scripting

check the status and send an email with status

Hi, We have a text file which has the following data. ISA~00~ ~00~ ~ZZ~VISTN ~ZZ~U1CAD ~051227~183 7~U~00200~000011258~0~P~< GS~FA~EE05J~U1CAD~051227~1831~000011258~X~002002 ST~997~0001 AK1~SH~247 AK2~856~2470001 AK5~A AK2~856~2470002 AK5~A... (3 Replies)
Discussion started by: isingh786
3 Replies
Login or Register to Ask a Question