views:

50

answers:

2

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.

A: 

this can be done using cron. i will prepare a more detailed answer shortly.

jusunlee
do you have root access to your server?
jusunlee
cron enables you to run scripts automatically at a specified time / date.
jusunlee
my current webserver won't let me have access to root or cron - but I can potentially move to being hosted by a friend's company - he will do anything that won't compromise the security
Robert
+1  A: 
  1. 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.

  2. 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.

  3. 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.

arbales