Visit Our UNIX and Linux User Community


Wants alternate to the Sleep option??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Wants alternate to the Sleep option??
# 1  
Old 01-12-2009
Lightbulb Need help to write a shell script without Sleep option??

I am new to Shell Scripting and I need help to write the following script in a different format...

This is the current script:
Code:
#!/usr/bin/ksh
environment=rms
export environment
. $AW_HOME/RETEK/exec/RETEK_ENVAR
ls -ltr $MMPOS/RTLOG* | tr -s " " | cut -d " " -f9 >$MMHOME/oracle/proc/bin/rtlogfiles.txt
touch $MMHOME/oracle/proc/bin/prom.1
while read LINE
do
 saimptlogi_running=1
 . $MMHOME/awbatch/refreshsql.sh saimptlogi
 echo $LINE 
 mv $LINE $LINE.1
 Date=`date "+%m%d%y%n"`
 awrun -m saimptlogi -args 1 Y $LINE.1 $MMHOME/oracle/proc/bin/bad.1 $MMHOME/oracle/proc/bin/item.1 $MMHOME/oracle/proc/bin/waste.1    $MMHOME/oracle/proc/bin/ref_item.1 $MMHOME/oracle/proc/bin/prim_variant.1 $MMHOME/oracle/proc/bin/varupc.1 $MMHOME/oracle/proc/bin/storeday.1 $MMHOME/oracle/proc/bin/prom.1 $MMHOME/oracle/proc/bin/codes.1 $MMHOME/oracle/proc/bin/error.1 $MMHOME/oracle/proc/bin/ccval.1 $MMHOME/oracle/proc/bin/storepos.1 $MMHOME/oracle/proc/bin/tendertype.1 $MMHOME/oracle/proc/bin/merchcodes.1 $MMHOME/oracle/proc/bin/partner.1 $MMHOME/oracle/proc/bin/supplier.1 $MMHOME/oracle/proc/bin/employee.1 $MMHOME/oracle/proc/bin/banner.1 $MMHOME/oracle/proc/bin/ref_mmrp.1 $MMHOME/oracle/proc/bin/igtax.1 " " Y
 sleep 140
done <$MMHOME/oracle/proc/bin/rtlogfiles.txt
sleep 90
while true 
do
    saimptlogi_running=`awexe jq |grep saimptlogi | grep -v REJ | wc -l`
    if [ $saimptlogi_running = 0 ]; then
       mv ls -ltr $MMPOS/RTLOG*.1 $MMHOME/arch
       break
    fi   
done;

Actually I want a script which will not wait for the sleep(i;e I don't want sleep option) rather it should find for the PID in the log directory
(Ex:- Jan_12.log
Mon Jan 12 01:43:48 Program: saimptlogi: PID=12409: Started by rms
Mon Jan 12 01:45:50 Program: saimptlogi: PID=12409: Thread 1 - Terminated Successfully
)and it will ensure that if the same PID will appear again then it should assume that the current program is finished, then it should execute the next program.

Can anyone please help me with it ...

Last edited by otheus; 01-12-2009 at 11:10 AM.. Reason: Formatting and [code] tags
# 2  
Old 01-12-2009
Maybe instead of sleep 90...
Code:
while [ ! -f $LOGDIR/pidfile ] 
do 
   sleep 1
done

# 3  
Old 02-19-2009
Data details

Bro...its not working....
I dont want the sleep option atall...
Currently because of this sleep140 even if the first job gets complete in one minute it is unnecessarily waiting for the next job....

I want a script which will not wait for the sleep rather it should execute the next job immediately once the first job completes successfully......

And to know if a job is completed successfully it should check for the PID in the log directory "abc/xyz/Jan_12.log"

(Ex:- more Jan_12.log
Mon Jan 12 01:43:48 Program: saimptlogi: PID=12409: Started by rms
Mon Jan 12 01:45:50 Program: saimptlogi: PID=12409: Thread 1 - Terminated Successfully )

and it will ensure that if the same PID will appear again then it should assume that the current program is fine.
# 4  
Old 02-19-2009
Quote:
Originally Posted by satyajit007
Currently because of this sleep140 even if the first job gets complete in one minute it is unnecessarily waiting for the next job....

I want a script which will not wait for the sleep rather it should execute the next job immediately once the first job completes successfully......
man wait
# 5  
Old 02-19-2009
Please elaborate it

Hey but i think in wait we have to mention the PID but here each and every job will be having different PID ..but the PPID will be same for all that is supp.6415......Since I am not an Unix expert rather am a new commer to unix...could you please elaborate how I will use the wait here in this particular script....that would be really helpfull........Thanks
# 6  
Old 02-19-2009
replace
Code:
sleep 140

by
Code:
wait $!

# 7  
Old 02-19-2009
Lightbulb

i am curious to know how wait $! will identify the PID ....because at the same time many other jobs will also be running....

Previous Thread | Next Thread
Test Your Knowledge in Computers #425
Difficulty: Medium
C# 1.0 was first released in December 2002.
True or False?

9 More Discussions You Might Find Interesting

1. Solaris

Unrecognized option: sparc-sun-Solaris2.10/bin/as: unrecognized option `-m32'

Hi, I installed some packages required by an app built with python. But when I try python setup.py install, I get the following error: /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.2.0/../../../../sparc-sun-solaris2.10/bin/as: unrecognized option `-m32' Could anyone tell me what's wrong... (4 Replies)
Discussion started by: Kimkun
4 Replies

2. HP-UX

Alternate for wget

Hi, Whats the alternate for wget in HP-UX ? (4 Replies)
Discussion started by: mohtashims
4 Replies

3. UNIX for Dummies Questions & Answers

Alternate for pwdx in HPUX

I need alternate command as pwdx does not work on HP-UX mymachine B.11.31 U ia64 3223107173 unlimited-user license (6 Replies)
Discussion started by: mohtashims
6 Replies

4. Shell Programming and Scripting

Alternate to SLEEP for EXPECT within BASH script?

Fairly new to the System Admin world, and this is my first post here, hoping to get some clarification. I am using a BASH script to automate some Logfile Archiving (into .tars). The actual logfiles are accessed through an SSH, so I have used the following EXPECT sub-script within my main BASH... (8 Replies)
Discussion started by: Goatfarmer03
8 Replies

5. Shell Programming and Scripting

recently introduced to the newer option for find...does an older option exist?

To find all the files in your home directory that have been edited in some way since the last tar file, use this command: find . -newer backup.tar.gz Is anyone familiar with an older solution? looking to identify files older then 15mins across several directories. thanks, manny (2 Replies)
Discussion started by: mr_manny
2 Replies

6. Shell Programming and Scripting

Wrapping 'sleep' with my 'resleep' function (Resettable sleep)

This is a very crude attempt in Bash at something that I needed but didn't seem to find in the 'sleep' command. However, I would like to be able to do it without the need for the temp file. Please go easy on me if this is already possible in some other way: How many times have you used the... (5 Replies)
Discussion started by: deckard
5 Replies

7. Shell Programming and Scripting

alternate lines

Hi, I'm new to Unix. I want to read the all the lines from a text file and write the alternate lines into another file. Please give me a shell script solution. file1 ----- one two three four five six seven newfile(it should contain the alternate lines from the file1) ------- one... (6 Replies)
Discussion started by: pstanand
6 Replies

8. Shell Programming and Scripting

option followed by : taking next option if argument missing with getopts

Hi all, I am parsing command line options using getopts. The problem is that mandatory argument options following ":" is taking next option as argument if it is not followed by any argument. Below is the script: while getopts :hd:t:s:l:p:f: opt do case "$opt" in -h|-\?)... (2 Replies)
Discussion started by: gurukottur
2 Replies

9. Shell Programming and Scripting

Alternate way for echo.

Hi, Is there any other command echo does. if I am doing this operation for each line in my file. So its taking very long time to process more than 1000 records. Is there any alternative way to write the above if statement (5 Replies)
Discussion started by: senthil_is
5 Replies

Featured Tech Videos