Sponsored Content
Top Forums Shell Programming and Scripting loop of killing and calling process Post 302101722 by 197oo302 on Thursday 4th of January 2007 03:38:29 AM
Old 01-04-2007
loop of killing and calling process

I make two process killing and calling one process
I want to do this repeatedly many time between the interval(sleep)
What will be the command to do this, can you make as one
do use sleep between and run clear the memory(sh sync.sh)
I need your advice,

the script will be like this

killps
sh sync.sh
sleep 30
callps
sleep 60
killps
sh sync.sh
sleep 30
callps
sleep 60

This is callps

#!/bin/sh

pspid=`ps -ef | grep "cap -d" | grep -v grep | awk '{print $2}'`
psmcn=`who am i | awk '{print $6}'`
logfile='/nccbs/bin/ps_reset.log'
if [ "$pspid" -eq "" ]
then
clear
echo " "
echo " " >> $logfile
echo `date '+%Y-%m-%d %H:%M:%S'`' Initialization Started '$psmcn >> $logfile
echo "PS Initializing......."
echo " "
sync.sh
echo `date '+%Y-%m-%d %H:%M:%S'`' PS Started '$psmcn >> $logfile
# /nccbs/bin/xterm -e cap -d
cap -d
sleep 2
echo `date '+%Y-%m-%d %H:%M:%S'`' PS Stopped '$psmcn >> $logfile
echo " " >> $logfile
else
echo
echo
echo Process Already Started...
echo " " >> $logfile
echo `date '+%Y-%m-%d %H:%M:%S'`' Process Already Started...' >> $logfile
echo " " >> $logfile
echo
echo
fi

This is killps

#!/bin/sh

pspid=`ps -ef | grep "cap -d" | grep -v grep | awk '{print $2}'`
psmcn=`who am i | awk '{print $6}'`
logfile='/nccbs/bin/ps_reset.log'
echo
if [ "$pspid" -eq "" ]
then
echo
echo PS is not running
echo `date '+%Y-%m-%d %H:%M:%S '`' PS Not running' >> $logfile
echo
else
# echo Provision PID : $pspid
# echo $psmcn
kill -9 $pspid
kill -9 $pspid
echo `date '+%Y-%m-%d %H:%M:%S '`' PS [ '$pspid' ] Killed '$psmcn >> $logfile
echo Process [ $pspid ] Killed Successfully
fi

echo ; echo

Last edited by 197oo302; 01-04-2007 at 05:12 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

killing a process

I can kill running processes on my linux red hat system using ctrl-c but cannot do it from command line of another terminal using kill -2 pid. Although I can kill them from command line using kill -9 pid and other signals. I would like to do it using the kill -2 pid. Thanks for your suggestions (6 Replies)
Discussion started by: bbhayana
6 Replies

2. Shell Programming and Scripting

Killing of a process and send a mail if the process doesnot come up within 2 minutes

Hi Friends, I am new to this forum as well as new to shell scripting. I have a problem here and i need someone to solve this. Let us consider there are two processes(abc & def).There is a script which kills these two processes(i.e killtheprocess abc). Here abc is the argument . There is a... (1 Reply)
Discussion started by: Prince89
1 Replies

3. UNIX for Dummies Questions & Answers

killing the process

Hi, First, I am running a scipt.While the script is running I realize that I dont want the script to be run so I am killing the script externally.Before the process gets terminated or killed it should delete all the temporary files created by the script.How to do this?Can anyone help me? ... (3 Replies)
Discussion started by: arthi
3 Replies

4. Shell Programming and Scripting

Killing process!!!!

Hi friends, i m in big trouble.... i have one script which connects two server ...like below.. script1.sh ------------------------------------- bash test.sh & eval x=$@ export x=`echo $x` #echo $x # ssh user@8.2.5.6 bash /mbbv/location/script.sh $x|sed '/Binary file/d'... (1 Reply)
Discussion started by: Shahul
1 Replies

5. Shell Programming and Scripting

Help needed in killing a process

I'm trying to kill a process which is in sleep mode and the parent PID is 1 but I can't kill it with "kill -9" command. Is there a way to kill this process without rebooting? Any help will be appreciated. Steve (10 Replies)
Discussion started by: stevefox
10 Replies

6. Shell Programming and Scripting

script not killing process!

i am using script to connect remotly to server and run some commands , one of these commands is to kill some process but tried different ways with no hope sshpass -p 'pass' ssh -o StrictHostKeyChecking=no server kill -9 `pgrep procs` getting error message "kill: bad argument count" ... (2 Replies)
Discussion started by: mogabr
2 Replies

7. Shell Programming and Scripting

Finding the age of a unix process, killing old processes, killing zombie processes

I had issues with processes locking up. This script checks for processes and kills them if they are older than a certain time. Its uses some functions you'll need to define or remove, like slog() which I use for logging, and is_running() which checks if this script is already running so you can... (0 Replies)
Discussion started by: sukerman
0 Replies

8. UNIX for Dummies Questions & Answers

calling process and going back to the main loop

hi everyone , i want to read an option and depending on the option call the program .For ex #! /bin/ksh export JAVA_HOME=/home/oracle/jdk1.6.0_20 echo " Please enter mod-modeler, dev - sqldeveloper" read choice if ; then echo ' SQL DEVELOPER IS STARTING NOW ... ' cd... (0 Replies)
Discussion started by: kdev
0 Replies

9. UNIX for Advanced & Expert Users

Killing A Stopped Process

UNIX Tutorial Five % kill %jobnumber Does that not work on a stopped process? I've tried to kill a stopped process and it is not working. Or do you need a certain type of shell for this to work? I don't see anything about this in my man pages. (3 Replies)
Discussion started by: cokedude
3 Replies

10. Shell Programming and Scripting

Killing the process ID's

Hi , I have a list of application process id's. Is there a way to kill all the process listed below using the script, except the once which are starting with " Genesis " adm 1522 ABC_Process.tra adm 1939 Genesis_Process.tra adm 2729 Genesis_Archive.tra adm 3259 xyz_Process.tra (5 Replies)
Discussion started by: murali1687
5 Replies
MSSQL_FIELD_SEEK(3)													       MSSQL_FIELD_SEEK(3)

mssql_field_seek - Seeks to the specified field offset

SYNOPSIS
bool mssql_field_seek (resource $result, int $field_offset) DESCRIPTION
Seeks to the specified field offset. If the next call to mssql_fetch_field(3) won't include a field offset, this field would be returned. PARAMETERS
o $result - The result resource that is being evaluated. This result comes from a call to mssql_query(3). o $field_offset - The field offset, starts at 0. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 Using mssql_field_seek(3) on the example for mssql_fetch_field(3) <?php // Connect to MSSQL and select the database mssql_connect('MANGOSQLEXPRESS', 'sa', 'phpfi'); mssql_select_db('php'); // Send a select query to MSSQL $query = mssql_query('SELECT * FROM [php].[dbo].[persons]'); // Construct table echo '<h3>Table structure for 'persons'</h3>'; echo '<table border="1">'; // Table header echo '<thead>'; echo '<tr>'; echo '<td>Field name</td>'; echo '<td>Data type</td>'; echo '<td>Max length</td>'; echo '</tr>'; echo '</thead>'; // Dump all fields echo '<tbody>'; for ($i = 0; $i < mssql_num_fields($query); ++$i) { // Fetch the field information, notice the // field_offset parameter is not set. See // the mssql_field_seek call below $field = mssql_fetch_field($query); // Print the row echo '<tr>'; echo '<td>' . $field->name . '</td>'; echo '<td>' . strtoupper($field->type) . '</td>'; echo '<td>' . $field->max_length . '</td>'; echo '</tr>'; // Move the internal seek pointer to the next // row in the result set mssql_field_seek($query, $i + 1); } echo '</tbody>'; echo '</table>'; // Free the query result mssql_free_result($query); ?> SEE ALSO
mssql_fetch_field(3). PHP Documentation Group MSSQL_FIELD_SEEK(3)
All times are GMT -4. The time now is 04:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy