Reputation: 8609
I have a database which stores the work my staff do. One particular query I run tells me how much money I owe them for the current month (month to date), based on the hours that I have recorded for them. However, I would like to store this information into a table itself, for various reasons, not least to record whether I have actually paid them for this.
I would like my system to automatically run this query on the last day of the month and input its values into the payments table. My system is using php & mysql.
Upvotes: 1
Views: 344
Reputation: 5536
Setup a controller action or script that is web accessible and does whatever you want it to do. Have it produce no output other than headers.
Setup a cron job that does something like "wget http://yourservername.net/do/this/thing". People will probably tell you to use curl instead, but I just like wget. You can acoomplish this by adding
42 4 1 * * "wget http://(your url here)"
to your crontab.
The cron job will contact your server and execute the action.
OR
If you cannot use cron, you can simply record the last time the action was completed in a database row and at every request/login/session, check to see if that time was greater than/equal to a month ago -- if it is, then you execute the command again and update the database row.
Upvotes: 1
Reputation: 492
this can be done using cron. i will prepare a more detailed answer shortly.
Upvotes: 0