Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 stackoverflow.com Mar 13 '13 at 5:41

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

3  
* * * * * /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

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.

share|improve this answer

Your Answer

 
discard

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.