Results 1 to 4 of 4

Thread: Execute a cron job from PHP

  1. #1
    Join Date
    Jul 2007

    Default Execute a cron job from PHP

    I have a question...this actually a little backward from what most people want.

    I want to have a PHP script trigger a Cron job(PHP DB backup script) to execute when certain DB changes take place. The reason I want it to occur like this is, I want this process to occur in the background and not affect the user as DB dumps may cause the browser to time out.

    I have a cron job set to automatically execute a PHP script daily to backup/replace a mysql dump file, I want to be able to execute this cron programmatically from the site.

    Anyone ever do this or is it even possible? Thanks in advance for any insight.

  2. #2
    Join Date
    Feb 2009


    You'd actually need to have the cron job run a php script that checks your database size and saves the size so that the next time the script is run you can compare the two sizes for differences. Then if there is a difference in the size, you'd just run the script you want to run for when changes have been made to your database. This page might help you get started on checking the DB size.
    Last edited by farcaster; 05-31-2011 at 07:35 AM. Reason: released from moderation

  3. #3
    Join Date
    May 2011


    Hmm, the cron job has a set schedule so it would be difficult to tell it to run only when database changes are made. What "certain DB changes" are you trying to monitor? There's probably an easier way to do it, let us know.

  4. #4
    Join Date
    Nov 2006
    Sydney, Australia


    The simplest way is to have the PHP script update a flag or flags that the cron job can test to see what if anything it needs to do this time.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts