Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

mySQL stored procedure... ??

Posted on 2005-05-14
5
Medium Priority
?
572 Views
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...

--ARCglide
0
Comment
Question by:ARCglide
  • 3
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
e-tsik earned 500 total points
ID: 14004706
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.

Enjoy!
0
 
LVL 4

Author Comment

by:ARCglide
ID: 14005327
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
0
 
LVL 4

Author Comment

by:ARCglide
ID: 14005414
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 http://www.oneplaceonly.com/usr/local/bin/php/var/www/html/scheduler_script.php" >> /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
------------------
REF: http://www.experts-exchange.com/Programming/Programming_Platforms/Linux_Programming/Q_21252022.html

--ARCglide
0
 
LVL 9

Expert Comment

by:e-tsik
ID: 14005612
hmm. Might work, this IS a dirty hack, though...

I would have tried just putting
1 * * * * lynx -dump http://www.oneplaceonly.com/usr/local/bin/php/var/www/html/scheduler_script.php

In your crontab
0
 
LVL 4

Author Comment

by:ARCglide
ID: 14006307
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.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month21 days, 3 hours left to enroll

810 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