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
APM(1)																	    APM(1)

NAME
apm - interface with the APM subsystem SYNOPSIS
apm [ -VvmMsSdin ] DESCRIPTION
This command requires the Advanced Power Management subsystem. If run without arguments it reads /proc/apm and presents the output in a human-readable format. Given a -S or -s option it requests that the machine be put into the APM standby or the APM suspend state, respectively. For a brief description of these states, see apmd(8). OPTIONS
-V, --version Print the version of the program and exit. -v, --verbose Also print version information for the APM subsystem. The APM subsystem consists of power-management hardware, firmware usually referred to as the APM BIOS and a driver in the operating system kernel. -m, --minutes Print the time remaining as a number of minutes. The default is to print the time remaining in "hours:minutes" format. -M, --monitor Continuously monitor and update the status information. Assumes that the standard output is a terminal. -S, --standby Request that the machine be put into the APM standby state. -s, --suspend Request that the machine be put into the APM suspend state. -d, --debug Print APM status information in a format more useful for debugging. Implies -v. FILES
/proc/apm AUTHOR
This program was written by Rik Faith (faith@cs.unc.edu) and may be freely distributed under the terms of the GNU General Public License. There is ABSOLUTELY NO WARRANTY for this program. The current maintainer is Avery Pennarun (apenwarr@worldvisions.ca). SEE ALSO
xapm(1), apmd(8). January 2004 APM(1)
All times are GMT -4. The time now is 07:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy