mySQL stored procedure... ??

Posted on 2005-05-14
Last Modified: 2007-12-19
I need to setup a server behaviour to send a notification to users when a mySQL stored date event has occured.
Namely: I have a start (datetime) and a duration (days) and once this event has expired (occured), I wish to fire a (php) function.

How can I setup this type of server-side behaviour? Thanx all...

Question by:ARCglide
    LVL 9

    Accepted Solution

    Hi :-)

    1. Running PHP scripts not from a web page requires the php binary. The problem is, at least on Red Hat, the PHP binary does not come with the RPM and you will have compile PHP yourself.

    2. You need to set up a cron job that runs every minute which fires up a program you will write in PHP. That program will look up the expired event and fire up that function you need
    Put this in crontab -e
    * * * * * /usr/local/bin/php /var/www/html/scheduler_script.php
    Replace /usr/local/bin/php with the actual path to php.

    The scheduler script will run the query that finds the expired events and run the function you require.

    LVL 4

    Author Comment

    Thanks for your answer e-tsik... !!

    The current setup is: Apache/2.0.50 (Unix) PHP/4.3.8 Server
    Are there any further resources available on the net for setting up crontab within this environment??

    Thanks again --ARCglide
    LVL 4

    Author Comment

    Is this a method for the Apache setup to run scheduler_script.php once per minute ??

    Use "crontab -e" is the normal command to setup the cron job.

    Or you can do...
    echo "1 * * * * lynx -dump" >> /var/spool/cron/`username`

    Then use "crontab -l" to check the result.
    Make sure your crond is running
    /sbin/service crond start
    chkconfig --level 2345 cron on

    LVL 9

    Expert Comment

    hmm. Might work, this IS a dirty hack, though...

    I would have tried just putting
    1 * * * * lynx -dump

    In your crontab
    LVL 4

    Author Comment

    E-tsik - thanks for the directional comments - I'll have a look into the use of (Apache) "crontab" and find the Apache 2.0 manual for more info.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
    Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL ( several years ago, it seemed like now was a good time to updat…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now