Sponsored Content
Full Discussion: Script runs in endless loop
Top Forums Shell Programming and Scripting Script runs in endless loop Post 302950184 by bayoo on Wednesday 22nd of July 2015 07:30:49 AM
Old 07-22-2015
Dear Singh,

Thanks for the quick response. Let me try give more insight to what am trying to do. This is like a check script to make sure that the number of instance for a running process doesnt not fall short than expected.

For example,

The process readgfile is suppose to run 4 instance at a time but for one reason one or two of the instance goes down, i want to be able to check the count of instance running and automatically restart thhose failed instance from this script.


I have added like this, but still noticed it runs more that expected instance. Any suggestion please.


Code:
#!/bin/ksh    

### To check a running process instance

################# readgfile process #################

a=`ps -ef | grep readgfile | grep -v grep | grep -v "readgfile /AFF /SNV1" | grep "/AFF /SNV"|wc -l `
while [ $a -lt 4 ]
do 
						echo "... readgfile /AFF /SNV is not running, trying to start it"
$BIN/readgfile /AFF /SNV /D0 1>> $LOG/readgfileNV_$sach.log 2>> $LOG/readgfileNV_$sach.err &          
$BIN/readgfile /AFF /SNV /D0 1>> $LOG/readgfileNV_2_$sach.log 2>> $LOG/readgfileNV_2_$sach.err &      
$BIN/readgfile /AFF /SNV /D0 1>> $LOG/readgfileNV_3_$sach.log 2>> $LOG/readgfileNV_3_$sach.err &      
$BIN/readgfile /AFF /SNV /D0 1>> $LOG/readgfileNV_4_$sach.log 2>> $LOG/readgfileNV_4_$sach.err & 

a=$((a+1))

done


##########  END #########


BR


Bayoo.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Endless loop - Fork function failed?

I need a quick script that will serve as a sort of "real time monitor" for watching some log files. I am using Bourne shell in HP-UX 10.20. I have basically created a script that never ends, unless of course I manually terminate it. Here's the script (it's called qhistory): clear echo "REAL... (3 Replies)
Discussion started by: cdunavent
3 Replies

2. Shell Programming and Scripting

Shell Script: want to insert values in database when update script runs

Hi , I am new to linux and also also to shell scripting. I have one shell script which unpacks .tgz file and install software on machine. When this script runs I want to insert id,filename,description(which will be in readme file),log(which will be in log file) and name of unpacked folder... (1 Reply)
Discussion started by: ring
1 Replies

3. Shell Programming and Scripting

Endless Loop

Hi, I'm pretty new to UNIX shell scripting and need some help. We have an Informatica interface that dumps any files that have errors into a directory. I need to check that directory periodically for any of up to 9 files that might be in it and run a specific process for each file found. The... (3 Replies)
Discussion started by: JeffR
3 Replies

4. Shell Programming and Scripting

[PHP] endless loop mimics a cron. Make sure only one instance is running

Hi, PHP user here. I'm using an endless loop to perform to mimic a cron. The script does something every 20 minutes. It sleep()s in the meantime. I have various checks that ensure that only instance can run, including a "gentleman agreement" locked file. However, I'd like to make sure... (2 Replies)
Discussion started by: jjshell
2 Replies

5. Shell Programming and Scripting

Preventing an endless loop with recursive grep

When finding a string in files within a directory, one can use this: grep -r "searchstring" dir/subdir/ > listofoccurrences.txt For brevity sake one can enter the intended directory and use this: grep -r "searchstring" . > listofoccurrences.txt which as I found out leads to an endless loop,... (2 Replies)
Discussion started by: figaro
2 Replies

6. Shell Programming and Scripting

KSH - Issue with endless loop.

First time post. I did a search so I didn’t see this specific issue. It seems to be a head scratcher for me. I have an hourly job that on rare occasions, gets into an endless loop. I’ve tried different scenarios but the current version does basically the following. Find all the *.arc files and... (18 Replies)
Discussion started by: Sylvan303
18 Replies

7. Shell Programming and Scripting

[Solved] Endless while loop when compare files

Hi All, I've written a script to read 2 files and compare the contents using while loop but somehow when $line is not found in test2, the script will continue looping. Below is my code, pls advise what could went wrong TIA Nick for line in test1.txt | while read line do grep -i... (4 Replies)
Discussion started by: Nick1971
4 Replies

8. UNIX for Dummies Questions & Answers

Script only runs as a particular user

Hi guys So I've got this PERL script that for one reason or another I need to run as a user other than the user that created the script. When I su - to another user the script won't run and doesn't give me any output as to why. No permission denied or anything like that. I've chmod 777'd the... (5 Replies)
Discussion started by: Jaymoney
5 Replies

9. UNIX for Beginners Questions & Answers

Help with accidental endless loop

I was practicing writing simple loops as I am a new bash user and I created this script, which turned out to be an endless loop where the echo output does not stop and I do not see where my mistake is. #!/bin/bash echo 'enter a number from 1 to 100' read number while do ... (2 Replies)
Discussion started by: goldenlinx
2 Replies
smd-loop(1)						 Sync Mail Dir (smd) documentation					       smd-loop(1)

NAME
smd-loop - iterates smd-pull and smd-push SYNOPSIS
smd-loop [-vt] DESCRIPTION
smd-loop runs smd-push and smd-pull at regular intervals as defined by the user in the ~/.smd/loop configuration file. On errors that are reported to be transient, it retries a second time before failing. The configuration file is line-oriented. Each line is composed of three space separated fields: pull-frequency, push-frequency and end- point-name. Frequencies are expressed in minutes, while endpoint name is a valid name for smd-pull(1) and smd-push(1). Lines beginning with # are considered as comments. The following example calls the command smd-pull default every 3 minutes, and smd-push default every 10. Example: # pull-frequency push-frequency endpoint-name 3 10 default OPTIONS
-v Increase program verbosity (printed on stderr) -t Just create a template configuration file if none FILES
~/.smd/loop SEE ALSO
mddiff(1), smd-server(1), smd-client(1), smd-push(1), smd-pull(1) AUTHOR
Enrico Tassi <gares@fettunta.org> 11 June 2012 smd-loop(1)
All times are GMT -4. The time now is 03:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy