Solaris / OpenSolarisThis forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
If you put the exit statement inside the while loop, it exits after the first iteration, hence you don't really need a loop: an if/then construct should be enough. If you don't see the loop terminates after a while, maybe its due to a long execution time of the mbpro command (or it sticks for some reason).
Will it try again if it doesnt find the prolog.log file in path. Coz the timing is 5AM, the file might get generated till 8AM (depends on some other process). So this loop has to try again and again and when found the file prolog.log it has to run this.?
That's not a good idea; what if your file doesn't show up at all; you will have another script start up at 5am the next day, and more after that. You will then need to ensure that only one script starts up at a time.
It will show up.. because this script runs mon to sat and prolog.log will showup anytime after 3am but have to make sure after prolog.log gets created our 5am script has to run. Here some time instead of 3am prolog.log file gets genereated at 6am. So if i check this condition and run my 5am script then it will run without a hitch. About another script running at that time doesnt matter here. Please advise. Can the above "if" condition full fills my need.
no, the "if" is not sufficient; you can change your while loop like so:
Code:
while [ ! -f /stage5_dp04/dump/prolog.log ]
do
# wait for file to show up
sleep 10
done
# out of loop ==> we have the file
$DLC/bin/mbpro -pf $PF -p $SCRIPTDIR/stage5/ncre-stg5.p
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
OK, as you say, your /stage5_dp04/dump/prolog.log file may not be there at 0500.
So, do a loop
Code:
while true
do
# is the file there?
if [ -f /stage5_dp04/dump/prolog.log ]
then
# yup, it is, do our thing
$DLC/bin/mbpro -pf $PF -p $SCRIPTDIR/stage5/ncre-stg5.p
# all done, get outta here
break
fi
# nope, ain't there; sleep for a half hour
sleep 30m
done
# now that we've done our thing, let's get rid of that file
rm /stage5_dp04/dump/prolog.log
Note that your version of sleep may not like the m (minutes) suffix; in that case just multiple whatever number of minutes you want to delay by 60 and use that value -- check your manual page for sleep.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.