Jump to content

Mysql Daily Action


23.12.2012
 Share

Recommended Posts

I'm working on this application, and I need to execute an action on the database daily, even if the computer is powered off. In big lines, a membership expires in 30 days. And I need to keep tracks of how many days there are left. So how can I have MySQL subtract 1 from 30 each day? Thanks in advance!

Edited by 23.12.2012
Link to comment
Share on other sites

This obviously isn't going to work unless the database server is running, but you need to set up a scheduled task to execute some code. Windows uses Scheduled Tasks for that, and Linux uses cron jobs. You can either have it execute a PHP script to do the update, or you can use a command line to execute mysql and have it run a series of queries from a text file.You could also just store the expiration date itself instead of the number of days until it expires, and then you don't need to count down.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...