Query: register_shutdown_function
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
REGISTER_SHUTDOWN_FUNCTION(3) 1 REGISTER_SHUTDOWN_FUNCTION(3) register_shutdown_function - Register a function for execution on shutdownSYNOPSISvoid register_shutdown_function (callable $callback, [mixed $parameter], [mixed $...])DESCRIPTIONRegisters a $callback to be executed after script execution finishes or exit(3) is called. Multiple calls to register_shutdown_function(3) can be made, and each will be called in the same order as they were registered. If you call exit(3) within one registered shutdown function, processing will stop completely and no other registered shutdown functions will be called.PARAMETERSo $callback - The shutdown callback to register. The shutdown callbacks are executed as the part of the request, so it's possible to send output from them and access output buffers. o $parameter - It is possible to pass parameters to the shutdown function by passing additional parameters. o $... -RETURN VALUESNo value is returned.ERRORS/EXCEPTIONS If the passed callback is not callable a E_WARNING level error will be generated.EXAMPLESExample #1 register_shutdown_function(3) example <?php function shutdown() { // This is our shutdown function, in // here we can do any last operations // before the script is complete. echo 'Script executed with success', PHP_EOL; } register_shutdown_function('shutdown'); ?>NOTESNote Working directory of the script can change inside the shutdown function under some web servers, e.g. Apache. Note Shutdown functions will not be executed if the process is killed with a SIGTERM or SIGKILL signal. While you cannot intercept a SIGKILL, you can use pcntl_signal(3) to install a handler for a SIGTERM which uses exit(3) to end cleanly.SEE ALSOauto_append_file, exit(3), The section on connection handling. PHP Documentation Group REGISTER_SHUTDOWN_FUNCTION(3)
Related Man Pages |
---|
halt(8) - mojave |
reboot(8) - mojave |
shutdown(3xnet) - opensolaris |
shutdown(8) - minix |
exit(3) - php |
Similar Topics in the Unix Linux Community |
---|
A script for shutdown |
emergency shutdown best practices. |
Script errors out only when its executed via job |
Application Cleanup during Linux Shutdown |
Screen Output Needed on every execution |