Here's what I have:
A user submits a page using a form. The page takes the user input and places it in a MYSQL database. It also calculates a time 3 days in the future and writes it to the user's mysql row. The user leaves on his or her merry little way.
Here's what I want next, but don't know how:
As soon as that future time is reached, a php script will be executed. The contents of the executed script are irrelevant- it's how to get it to call the script at the right time without being prompted by a user calling a page that's causing me strife.
I have looked into cron jobs a little (I'm new to the concept). Could I write one cron job now that would last forever, and that would automatically run a script that checks the db for expired future dates? If so, how do I get the cron job to do this? And how do I write a cron job? (I do have admin access to the server).
I hope that makes sense. I'm a little lost.
set cron jobs with php script?
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Yes, a cron job is what you're wanting.
Set it to run every minute. Have it execute a script that checks the database for users who's time expires during that minute. The script should do whatever is needed for those users. It should also mark them as being handled. This way you can also perform operations on other accounts that may have been missed by a previous run (or absence thereof.)
We've had several threads dealing with the syntax of cron. There are also lots of web sites that show the various parts of setting a cron job.
Set it to run every minute. Have it execute a script that checks the database for users who's time expires during that minute. The script should do whatever is needed for those users. It should also mark them as being handled. This way you can also perform operations on other accounts that may have been missed by a previous run (or absence thereof.)
We've had several threads dealing with the syntax of cron. There are also lots of web sites that show the various parts of setting a cron job.