Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Hi linux gurus and non gurus.
I have a little problem, hope I'll find a solution here.
Shell script hangs up periodically (after 1-3 weeks of work).
What can cause such behavior?
Content of the script is pretty simple:
an infinite loop in which every 2 seconds I call php script, thats it.
Is there any limitation for shell script execution time?
When I look into ps list it shows me that not only shell script but php script also hangs up. So can php script be the root of the problem?
Any advice, help, assumption will be appreciated.
Well, one thing to check... Is the php instance going away?
Another possibility... Does the php script take longer than 2 seconds to run and are there things like locked files that might become a problem? One thing to try is to expand the sleep time to maybe 10 seconds. You can also use that to diagnose the problem by checking if the sleep is running in a ps.
Just some random thoughts.
Edit: Just realized you are not backgrounding the php script, so a previous run interfering isn't likely. But, if you use lock/run files or stuff like that, check to make sure you are cleaning them up right in all cases.
The script connects to broker gets latest quotes and writes them to DB,
and yes, sometimes it can take longer than 2 seconds to run.
But I guess this can't cause the problem... OR can???
Thanks for the idea ($?), I'll try to modify script a little bit
to report me if the script fails.
Will the call to script.php return anything if it hangs?
I mean will I be able to check the return code when script hangs?
Last edited by junior_unix_user; 04-07-2010 at 08:25 AM.
The symptoms described in the OP are entirely consistent with the php script hanging so the quest for a solution is better directed at the php script than the shell script.
If it is not possible to fix the php script so it doesn't hang, it is probably possible to program the shell script to kill it if it does not complete within a reasonable time (and to do any necessary cleaning up).
EDIT: in answer to "will I be able to check the return code when script hangs?" and presuming "script" here refers to the php script then no, you will not. A process running a hung script has not exited so has not set an exit code so has not set a return code (a return code is part of an exit code) so there is no return code to check.