kryppienation Posted December 2, 2008 Share Posted December 2, 2008 I am trying to set a certain field "daily" to reset to the value of 200 in an entire table throughout all records. I am not sure how to work with time. I would like to also watch the time remaining until the reset happens... Now this time does not have to live, just a post of the time remaining that updates when i refresh is quite fine. I am not sure if i need to make another database table to hold the information or not, i am sure that i most likely do... which is completely fine. I am wondering if someone knows how i can do this? Thanks! Quote Link to comment Share on other sites More sharing options...
sKunKbad Posted December 2, 2008 Share Posted December 2, 2008 search for cron or crontab. Quote Link to comment Share on other sites More sharing options...
kryppienation Posted December 2, 2008 Author Share Posted December 2, 2008 I only need to do this one time in a 24 hours period. Like once a midnight... i don't know if that makes it easier or not... but perhaps a bit less confusing. Basically i need to know how to run an update statement every 24 hours. Quote Link to comment Share on other sites More sharing options...
waynew Posted December 2, 2008 Share Posted December 2, 2008 Place the update inside a php script as you normall would and then use cronjob (Linux) or scheduled task(Windows) to execute that script every 24 hours. Quote Link to comment Share on other sites More sharing options...
kryppienation Posted December 4, 2008 Author Share Posted December 4, 2008 alright, i wrote the script and it works when i call it in my browser. I tried to do a scheduled task and i used the file as my file to run... when the time came, the file opened in mozilla... but it opened and nothing happened. The problem is when i called the file for it to work the first time, i used the url of the site. localhost/mystuff/runthisfile.php when it opened using the scheduled task it opened with the following: file:///C:/root/mystuff/runthisfile.php Does anyone know how i can get this file to actually run the script? I put the code in there just incase it might be userful it's very simple though. <?php include_once('../includes/db.php'); $setdaily = 'update users set daily = "200"'; DB::connect($DB_database); DB::query($setdaily, "Set all user's to 200 daily"); DB::close(); ?> Quote Link to comment Share on other sites More sharing options...
chronister Posted December 4, 2008 Share Posted December 4, 2008 Well, when you run the file using scheduled task like that, you are simply opening the file.... but it is not running it through the php parser. You can make it do that with a little messing around with the PHP CLI which is a command line executable that will allow you to run php scripts that way. You would basically then set the scheduled task to be c:\root\php.exe fileToRun.php Or you can even possibly set the scheduled task to run the file on the server http://www.yoursite.com/filetorun.php or http://localhost/fileToRun.php Linux crontab is really much easier. Nate Quote Link to comment Share on other sites More sharing options...
kryppienation Posted December 4, 2008 Author Share Posted December 4, 2008 Ok I have done that, it still didn't change the values in my database. here is what i got. this is all of the stuff in "RUN:" C:\xampp\php\php.exe C:\xampp\htdocs\kryppienation\admin\changemotivation.php it opens the php.exe CLI but it's not reading the file... i also tried: C:\xampp\php\php.exe changemotivation.php when i did this i made sure that the changemotivation.php and the included db.php where in the c:\xampp\php folder. didn't work either Thanks. [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
chronister Posted December 4, 2008 Share Posted December 4, 2008 Check this out. wget for windows. http://users.ugent.be/~bpuype/wget/ I was able to run a php file on my webserver using it. In the scheduled task place this in it. C:\wget.exe -q -O nul http://yoursite.com/path/to/file The -q makes it run quiet, the -O writes the output to FILE and nul is the file it goes to ..... I think that is the way the switches work. But it does work without issue. Nate Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.