Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3221862
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:55:30+00:00 2026-05-17T15:55:30+00:00

Is it possible to invoke a function when a cron process is killed from

  • 0

Is it possible to invoke a function when a cron process is killed from the command line (via Ctrl+c) or with the kill command?

I have tried register_shutdown_function(), but it doesn’t seem to be invoked when the script is killed, but does get invoked when the script ends normally.

I am trying to log the result to a file and update a database value when a cron instance is killed automatically (ie. has been running too long).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:55:31+00:00Added an answer on May 17, 2026 at 3:55 pm

    According to a comment in the manual on register_shutdown_function(), this can be done the following way:

    When using CLI ( and perhaps command
    line without CLI – I didn’t test it)
    the shutdown function doesn’t get
    called if the process gets a SIGINT or
    SIGTERM. only the natural exit of PHP
    calls the shutdown function. To
    overcome the problem compile the
    command line interpreter with
    --enable-pcntl and add this code:

     <?php
     declare(ticks = 1); // enable signal handling
     function sigint()  { 
        exit;  
     }  
     pcntl_signal(SIGINT, 'sigint');  
     pcntl_signal(SIGTERM, 'sigint');  
     ?>
    

    This way when the process recieves one
    of those signals, it quits normaly,
    and the shutdown function gets called. … (abbreviating to save space, read the full text)

    If that is too much hassle, I would consider doing the timing out from within PHP by setting a time limit instead. Reaching the limit will throw a fatal error, and the shutdown function should get called normally.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible in Delphi to have a class method invoke an inherited instance
I would like to know how it is possible that C# Invoke function can
Is it possible to use boost::fusion::invoke function to call a function that has default
Is it possible to somehow invoke a non-global function (i.e. a method of a
Just curious here: is it possible to invoke a Windows Blue Screen of Death
Does someone knows if it's possible to dynamically create a call chain and invoke
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
Possible Duplicate: How do you send email from a Java app using Gmail? How
I would like to track (run some code - or invoke function) when the
How would I use DLLImport pinvoke to invoke a function i wrote in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.