Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

migrated from Mar 13 '13 at 5:41

This question came from our site for professional and enthusiast programmers.

* * * * * /usr/bin/php /path/to/your/script – Marc B Mar 12 '13 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 '13 at 15:24
My website is hosted. Is /usr/bin/php will work? coz its shows something like: /home/jnstech – Mohammad Faisal Mar 12 '13 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 '13 at 15:25
I'm sorry. But I'm unable to understand your last comment @MarcB – Mohammad Faisal Mar 12 '13 at 15:27
up vote 2 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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