Rollins Posted July 23, 2013 Share Posted July 23, 2013 Hey all! i was wondering if you could help me with the following... I want to pull some data/file from a foreign server at a specific time, every day. data would be inserted in a DB for users to search data they require. i did some research and came on cronjobs....not supported by my provider unless i get a upgrade and that would more then tripple my costs. don't wanna do that.... then i figured that i could create a page that would run through even when the browser was closed....so i wrote this but it is unstable and fails on me more than halve of the time. the next step for the script would be checking conditions(read time) where right it would execute code to retrieve the files. session_start(); //ignore user abort ignore_user_abort(true);//error report ini_set('display_errors', 1); error_reporting(E_ALL);/get time $date = date_create();//echo time echo $date->format('Y-m-d H:i:s');//check//+1 every refresh //get count $counter = $_SESSION['counter']; //add 1 if($counter > 0 ){ $counter = $counter; } else{ $counter = 0; } $counter++; $_SESSION['counter'] = $counter; echo '<br><br>'.$counter.'<br><br>'; //refresh every 60 sececho '<meta http-equiv="refresh" content="60; url=http://www.some.link.com/GetDataFromURL.php">';?> there is one fault (afik) in this code and that is the time limit...not able to set it unless i turn of "save mode" in the provider settings wich limits the php-enigine to run harmfull scripts...(roughly translated). i have read about the socalled "poor mans cron"...run it on users pages but that would limit the users and i don't want that either...and there is no guarantee that there will be a user every day. is there hope for the script that i wrote? if so, how can i improve it? Is there a alternative/scripting for cronjobs? can the DB(mysql) trigger events? any thoughts and comments are welcome! Roll. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 23, 2013 Share Posted July 23, 2013 First, that is not going to run if the browser is closed. The browser is needed to send a request to the server. You can create a scheduled task on your own computer that uses a command line to open a browser to the URL of that script and then close the browser after a while, but your computer will need to be running in order for that to happen also. Link to comment Share on other sites More sharing options...
Rollins Posted July 23, 2013 Author Share Posted July 23, 2013 (edited) hmm i would rather not leave my laptop on the entire day..and i travel sometime so... could it be triggered from a other website? and the code...could it run...with ignore_user_abort(true);set_time_limit(0); it should right? Edited July 23, 2013 by Rollins Link to comment Share on other sites More sharing options...
justsomeguy Posted July 23, 2013 Share Posted July 23, 2013 ignore_user_abort shouldn't matter if it's being triggered automatically, that only matters if you open it in a browser and press the stop button to cancel the request (or the request gets canceled another way). You can trigger it from a cron job on another server though. You need a cron job or scheduled task (same thing) somewhere to initiate the request. It doesn't really matter if it's on your server or another computer, as long as the computer can connect to your server. Link to comment Share on other sites More sharing options...
Rollins Posted July 23, 2013 Author Share Posted July 23, 2013 oke...thanks for those replies! ignore_user_abort is more used for keep running scripts already started...by what or who ever? i just found this site...did you ever hear from it? or anything like that? http://www.mywebcron.com/home.php Link to comment Share on other sites More sharing options...
justsomeguy Posted July 23, 2013 Share Posted July 23, 2013 No, I haven't heard of that. Link to comment Share on other sites More sharing options...
Rollins Posted July 27, 2013 Author Share Posted July 27, 2013 I Registered on http://www.mywebcron.com/home.php ....made a page that inserts a date and time in a DB when hit. tested it...works. setup the cron...tested it through their "execute" link, "check" wich gets the html wich worked...... and let it go for a day. Out of the 1200+ crons registered on their site i was hit....2 times. after 2 days still no reply from support... i think i will check some other sites... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now