I want one of my PHP file to be executed when the cron job is executed. I want to do this for updating the database of every users. It is a Banking application project and I need to update every user's account with interest amount. Any other possible approach/suggestion welcomed.

  • 3
    * * * * * /usr/bin/php /path/to/your/script
    – Marc B
    Mar 12, 2013 at 15:23
  • @MarcB — That is running a PHP script as a cron job, not running it when a cron job is created.
    – Quentin
    Mar 12, 2013 at 15:24
  • My website is hosted. Is /usr/bin/php will work? coz its shows something like: /home/jnstech Mar 12, 2013 at 15:24
  • you want to keep track of who's setting cron jobs? not really possible without a lot of hacking. e.g. monitoring crontab files, wrapping the cron executable, blah blah blah.
    – Marc B
    Mar 12, 2013 at 15:25
  • I'm sorry. But I'm unable to understand your last comment @MarcB Mar 12, 2013 at 15:27

1 Answer 1


Since there is no standard "A cron job has been created" hook, this would be somewhat non-trivial.

I suppose you could hack cron and run your own custom build of it that would keep a history of the jobs it had seen and run the PHP script if it saw a new one.

Alternatively you could watch for changes to the various files/directories that cron jobs are stored in (e.g. /var/spool/cron/ and /etc/cron.*/) using either Inotify or its equivalent on your OS or a cronjob that looks for changes every few minutes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.