How can a Perl script detect when it's being "properly" shut down and execute a last bit of code when that happens? I want to make a script that should run 24/7 but have it write something to a file when it's "gracefully" shut down (i.e. ending its task with Task Manager), so that if my computer loses power suddenly or is shut down forcefully, the script will know that this happened once the computer starts back up and it can check that file that it should've written.
So how can Perl differentiate between being terminated and having the whole computer shut down forcefully?
I've tried experimenting with the DESTROY block in Perl in some of my past projects, but it always seems that this block was never really called no matter how the script died. Any pointers?
So how can Perl differentiate between being terminated and having the whole computer shut down forcefully?
I've tried experimenting with the DESTROY block in Perl in some of my past projects, but it always seems that this block was never really called no matter how the script died. Any pointers?