B0b Posted May 13, 2010 Share Posted May 13, 2010 Hi everyone, I got a very sexy problem here: I need to run a script for several hours and it tend to magically stop after few hours (could be 50 minutes up to a dozen hours). I decided to log some informations to spot the problem using register_shutdown_function(), which works fine when manually stopped, but the log is NOT saved (the function is NOT executed) when it crashes?! I did used an absolute path for fwrite(). I did remove all time constraints, be it ignore_user_abort( true ) or set_time_limit( 0 ). There is no related errors in PHP logs. Any clue why my register_shutdown_function isn't executed? Quote Link to comment https://forums.phpfreaks.com/topic/201650-php-does-not-execute-register_shutdown_function/ Share on other sites More sharing options...
Joshua4550 Posted May 13, 2010 Share Posted May 13, 2010 I'm not sure if anything similar would happen in PHP, but once encountered this problem in Java - Is there any kind of timeout limit? Quote Link to comment https://forums.phpfreaks.com/topic/201650-php-does-not-execute-register_shutdown_function/#findComment-1057821 Share on other sites More sharing options...
Mchl Posted May 13, 2010 Share Posted May 13, 2010 Registers the function named by function to be executed when script processing is complete or when exit() is called. My understanding is, that 'when script processing is complete' assumes successful completion, i.e. any errors thrown cause the script to exit prematurely and thus the function is not called. Try registering your logging with set_error_handler [edit] Well I was wrong, as this piece of code demonstrates: <?php function foo() { echo 'shutdown'; } register_shutdown_function('foo'); echo 1/0; Quote Link to comment https://forums.phpfreaks.com/topic/201650-php-does-not-execute-register_shutdown_function/#findComment-1057914 Share on other sites More sharing options...
B0b Posted May 13, 2010 Author Share Posted May 13, 2010 Thanks for the replies, guys. Yes, indeed, the function got to be triggered even though the script normally finish. It seems like everything on the server just dies at a certain moment. Note that this doesn't only happen with a single script, but all instances of this script and, this, all at the same moment regardless when they were started. It sounds more like a server sided issue. Yet, any clue? Quote Link to comment https://forums.phpfreaks.com/topic/201650-php-does-not-execute-register_shutdown_function/#findComment-1058018 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.