AM very new to shell scripting and try to run a simple do while loop statement, but it ends up running endlessly. please can anyone assist, dunno what am doing wrong, any useful suggestions will be welcomed.
Welcome to forum, a special thanks to you for using code tags for commands and codes used in your post. I can see there is NO increment given in your code for variable named a so condition in loop will be always TRUE that's why it is going to be endless, please add so and this should be fine then, though I am not sure about your complete requirement but for your question this should to the trick.
Add this before the end of the loop, as per thumb rule.
Thanks,
R. Singh
Last edited by RavinderSingh13; 07-22-2015 at 08:26 AM..
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.
I am seeing you have mentioned you need to check count of process readgfile but you have given grep -v "readgfile /AFF /SNV1" which means grep will negate the search where string "readgfile /AFF /SNV1" is coming in any process. So you can try with following.
Also if above doesn't work, then following are my suggestions on same.
1st: Try to search for exact process which you want to monitor.
2nd: Are these four process which you mentioned are related to each other means, is there one parent id which is going to create rest of child ids? If yes then you should have only script which is supposed to STOP and START readgfile process. If you have separate all 4 readgfile processes then you may need to start the exact process which is DOWN in spite of starting all process.
3rd: Add some more points if needed please to be better understanding on this.
Hope this helps.
Thanks,
R. Singh
Last edited by RavinderSingh13; 07-22-2015 at 08:51 AM..
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)
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)
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)
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)
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)
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)
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)
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)
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)