I have a serious problem and Im sure im just doing something stupid
######Start Load
while [ `< /export/home/mldwh/rkem_refresh/int_load/logs/iteration.log` -lt 15 ]
do
/export/home/mldwh/rkem_refresh/int_load/scripts/rkem_refresh.sh
sleep 10
while [ -a /export/home/mldwh/rkem_refresh/int_load/logs/int_rkem_move_running.txt ]
do
sleep 5
done
done
######Log and Runstats
sleep 10
echo "2nd 15 iterations finished" >> /export/home/mldwh/rkem_refresh/int_load/logs/Int_master.log
echo 0 > /export/home/mldwh/rkem_refresh/int_load/logs/iteration.log
db2 "CALL SYSPROC.ADMIN_CMD('runstats on table CENDW.DW_RKEM_MOVE_TBL with distribution and detailed indexes all shrlevel change')" >> /export/home/mldwh/rkem_refresh/int_load/logs/Int_master.log
db2 "CALL SYSPROC.ADMIN_CMD('runstats on table CENDW.DW_RKEM_MOVE_UPDATE_TBL with distribution and detailed indexes all shrlevel change')" >> /export/home/mldwh/rkem_refresh/int_load/logs/Int_master.log
sleep 10
######Start Load
while [ `< /export/home/mldwh/rkem_refresh/int_load/logs/iteration.log` -lt 15 ]
do
/export/home/mldwh/rkem_refresh/int_load/scripts/rkem_refresh.sh
sleep 10
while [ -a /export/home/mldwh/rkem_refresh/int_load/logs/int_rkem_move_running.txt ]
do
sleep 5
done
done
What I want to do is run the .sh file 15 times and then do some stuff and then run the .sh file 15 times again. I put the loop inside the loop (where i think my problem is) to make sure that the outer loop waited untill the .sh file was done before calling it again.
But what I am getting......ohh man this thing is spawning so many instances of the code that I have to chmod -x just to stop it.
you specified a while loop that do repetition if some counter is less than 15. Where is the counter? I presume its the value in the iteration.log file and int_rkem_move_running.txt files? if it is, then you have to update them to reflect a new counter everytime.
The counter is in the iteration.log file and it is incrmented durring the last step of the .sh file
the int_rkem_move_running.txt is a "seed" file that is created at the begining of the .sh script and deleted at the end of the .sh script.
The iteration seems to work I see it loop, but for some reason it seems to call the .sh file many times before it finishes. I.E. the loop isnt waiting for the .sh to finish before it calls another one.
I'm just noting that those two lines I quoted are not valid in bourne - thus prompting the question of which shell.
The `< file` thing is unique to ksh as far as I can tell and is an aliase for wc
The -a makes no sense to me at all - I'm used to it being a logical and between two expressions.
$ cat num
10
$ echo $(< num)
10
$ echo `< num`
10
$ [ -a num ] && echo ok
ok
$
$(< num) is the contents of the file called num. I have seen this often. I have never seen `< num` before and it is not documented, but it seems to work. Many versions of ksh allow -a or -e to test if an item is a file sysetm object of any kind (not just a file, not just a directory, not just a symlink, etc). But -e and -a are not super standard even among versions of ksh.
I agree about needing more info. A loop must initialize a loop counter, increment it, and test it. I see one script that sets /export/home/mldwh/rkem_refresh/int_load/logs/iteration.log to zero. And another that tests it. No increment though. And I do not see how these script fragments inter-relate.
Does this shed more light onto the problem? Im realy behind on a deadline and I need this loop to work so that I can enjoy the vacation that I am on. Any info would be great