Sponsored Content
Full Discussion: Script to start process
Top Forums Shell Programming and Scripting Script to start process Post 303001941 by simpsa27 on Tuesday 15th of August 2017 05:40:35 AM
Old 08-15-2017
Hi

I am currently using a bash script.

I want to create a script when I am checking if apmccctrl.sh is running & if it isn't running I want to be able to start it up and check again.

If the shell script is running I want to be able to return a status of "running" or number 1 for example.
If found it isn't running I want it to try and start it up and wait 60 seconds to then again check if it has started up successfully or not.
If failed again I want it to return "not running or 0 for example so we are able to alert on it.
Hope this makes it easier to explain.

I am using Putty version 0.63

This is what I have created so far but even if I shutdown the apmccctrl.sh I still get a return code of 1.

Code:
acc_status_check=$(${ACC_HOME}/apmccctrl.sh status)

if acc_status_check="CA APM Command Center Agent Controller is running"

then
acc_status="1"

else
/opt/ca/APMCommandCenterController/apmccctrl.sh start
sleep 60
/opt/ca/APMCommandCenterController/apmccctrl.sh
if acc_status_check="CA APM Command Center Agent Controller is not running."
then
acc_status="2"

fi
fi

echo $acc_status

Code:
[apm@ccbapprts1 enterprisemanager]$ ${ACC_HOME}/apmccctrl.sh status
CA APM Command Center Agent Controller is running: PID:23414, Wrapper:STARTED, Java:STARTED
[apm@ccbapprts1 enterprisemanager]$ ./epagent_enterprise_manager_metrics.sh
1
[apm@ccbapprts1 enterprisemanager]$ ${ACC_HOME}/apmccctrl.sh stop
Stopping CA APM Command Center Agent Controller...
Stopped CA APM Command Center Agent Controller.
[apm@ccbapprts1 enterprisemanager]$ ./epagent_enterprise_manager_metrics.sh
1
[apm@ccbapprts1 enterprisemanager]$


Last edited by RudiC; 08-15-2017 at 07:17 AM..
 

10 More Discussions You Might Find Interesting

1. Programming

get process start time

Hi all, I like to know how can I get currenlty running process start time and date , I know only porcess id in solaris and hp-ux and what is command to get same using ps with switch. Thanks Naeem (1 Reply)
Discussion started by: naeem ahmad
1 Replies

2. Shell Programming and Scripting

how to start a process and make it sleep for 5 mins and then kill that process

how to start a process and make it sleep for 5 mins and then kill that process (6 Replies)
Discussion started by: shrao
6 Replies

3. Shell Programming and Scripting

How to start a process.. from a different host ...

Hi ! I want to start and stop a process... on different machines(HOSTS) example : I have machine1..machine2..machine3 And I have a NFS file system. (Wlsuite/myfile/) I'm writing a script that will start processes in machine1.... machine2.... Preferably.. I dont want to log... (1 Reply)
Discussion started by: dashok.83
1 Replies

4. Shell Programming and Scripting

Script - How to automatically start another process when the previous process ends?

Hi all, I'm doing automation task for my team and I just started to learn unix scripting so please shed some light on how to do this: 1) I have 2 sets of datafiles - datafile A and B. These datafiles must be loaded subsequently and cannot be loaded concurrently. 2) So I loaded datafile A... (10 Replies)
Discussion started by: luna_soleil
10 Replies

5. Shell Programming and Scripting

Ksh Script to get the start minute of n number of process

How can i write a script.? which lists all X process and gets the start minute of each of them. thanks (1 Reply)
Discussion started by: Anteus
1 Replies

6. UNIX for Dummies Questions & Answers

cant start httpd process

httpd status is stopped.cant start it again by : /etc/init.d/httpd restart or /etc/init.d/httpd/start help needed (2 Replies)
Discussion started by: raksha.s
2 Replies

7. UNIX for Advanced & Expert Users

how to start a process killable by all

Hi, Is there a way to start a process that any other user would have the privs to kill? Thanks. (1 Reply)
Discussion started by: rebelbuttmunch
1 Replies

8. Shell Programming and Scripting

Solaris+Perl script to get process start date

Hi all, after reading the post: * https://www.unix.com/solaris/101653-how-get-process-start-date-time-solaris.html I wrote my perl script and it worked like a charm. This script is called every 5 minutes by the monitoring server crontab and is executed on the remote network elements via ssh (the... (6 Replies)
Discussion started by: Evan
6 Replies

9. UNIX for Dummies Questions & Answers

Script to start background process and then kill process

What I need to learn is how to use a script that launches background processes, and then kills those processes as needed. The script successfully launches the script. But how do I check to see if the job exists before I kill it? I know my problem is mostly failure to understand parameter... (4 Replies)
Discussion started by: holocene
4 Replies

10. UNIX for Dummies Questions & Answers

Process Scheduling where to start

Hello, i'm absolutely new to the whole Operating Systems thing. I am pretty much level 0. My assignment is to "simulate the execution of a stream of processes by a computer system, one CPU, many terminals 12 disk drives, 30 public mailboxes. The professor runs a series of inputs which is a... (1 Reply)
Discussion started by: JaneSkylar
1 Replies
SHLOCK(1)						      General Commands Manual							 SHLOCK(1)

NAME
shlock - create lock files for use in shell scripts SYNOPSIS
shlock -p pid -f name [ -b ] [ -u ] [ -c ] DESCRIPTION
Shlock tries to create a lock file named name and write the process ID pid into it. If the file already exists, shlock will read the process ID from the file and test to see if the process is currently running. If the process exists, then the file will not be created. Shlock exits with a zero status if it was able to create the lock file, or non-zero if the file refers to currently-active process. OPTIONS
-b Process IDs are normally read and written in ASCII. If the ``-b'' flag is used, then they will be written as a binary int. For compatibility with other systems, the ``-u'' flag is accepted as a synonym for ``-b'' since binary locks are used by many UUCP pack- ages. -c If the ``-c'' flag is used, then shlock will not create a lock file, but will instead use the file to see if the lock is held by another program. If the lock is valid, the program will exit with a non-zero status; if the lock is not valid (i.e., invoking shlock without the flag would have succeeded), then the program will exit with a zero status. EXAMPLES
The following example shows how shlock would be used within a shell script: LOCK=/var/run/innd/LOCK.send trap 'rm -f ${LOCK} ; exit 1' 1 2 3 15 if shlock -p $$ -f ${LOCK} ; then # Do appropriate work else echo Locked by `cat ${LOCK}` fi HISTORY
Written by Rich $alz <rsalz@uunet.uu.net> after a description of HDB UUCP locking given by Peter Honeyman. This is revision 1.9, dated 1996/10/29. SHLOCK(1)
All times are GMT -4. The time now is 08:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy