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!
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.
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.
I would say **highly likely**......In your BASH script, there is not much to go wrong.
If "script.php" hangs, then the container script will hang also.
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.
Just guessing:
The container script waits for script.php to finish. If you kill the latter, then that never happens.
In the container script, try adding "echo $?" after the call to script.php. This prints the return code from the php script. In normal operation, it should print "0" each time that script.php runs.
nuwen52, grail
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???
pixellany
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?
Thanks.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.