poirot Posted June 2, 2006 Share Posted June 2, 2006 OK, I've posted this a year ago; but since I got no answer I'll post it again.How do you make PHP scripts act like cron jobs? For example, you need to "lock" a page on a certain date. (after that it will no longer be visible).You could make it check for expiration every time the script is loaded... BUT this wouldn't be a great idea IF the script is accessed often.And what I can't do with something like this: email a "daily digest" of some message board to myself or whoever is subscribed to it. Is there any way, besides cron jobs, to make scripts execute themselves in a programmed time?Thanks in advance [img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /] Quote Link to comment https://forums.phpfreaks.com/topic/11057-cron-jobs/ Share on other sites More sharing options...
.josh Posted June 2, 2006 Share Posted June 2, 2006 umm...no. unless you wrote your own program in like c++ or something to execute it, and always have the program running. but what's the point? that's what cron jobs are for. Quote Link to comment https://forums.phpfreaks.com/topic/11057-cron-jobs/#findComment-41328 Share on other sites More sharing options...
nogray Posted June 2, 2006 Share Posted June 2, 2006 you can also call the php from your cron job "php /path/to/your/php/script.php"and you need the path to the php compiler (I think that what it's called) in the tob of you php file "#!/usr/local/bin/php -q" Quote Link to comment https://forums.phpfreaks.com/topic/11057-cron-jobs/#findComment-41330 Share on other sites More sharing options...
poirot Posted June 3, 2006 Author Share Posted June 3, 2006 Basically I need an alternative for Cron Jobs just in case my Host doesn't support them. Quote Link to comment https://forums.phpfreaks.com/topic/11057-cron-jobs/#findComment-41339 Share on other sites More sharing options...
litebearer Posted June 3, 2006 Share Posted June 3, 2006 Setup a taskscheduler on your local pc to run your browser (pointed at the appropriate php script on your host) at the appointed time interval. Quote Link to comment https://forums.phpfreaks.com/topic/11057-cron-jobs/#findComment-41347 Share on other sites More sharing options...
poirot Posted June 4, 2006 Author Share Posted June 4, 2006 Thanks for the suggestion guys ... If I use my computer though it may not be reliable since it's not on 24/7.I guess the only way is to find a server with Cron Jobs and remotely execute them... Quote Link to comment https://forums.phpfreaks.com/topic/11057-cron-jobs/#findComment-41767 Share on other sites More sharing options...
.josh Posted June 4, 2006 Share Posted June 4, 2006 you know..i was gonna say before, if a host doesn't offer the ability to run cron jobs... why bother even going with them? Quote Link to comment https://forums.phpfreaks.com/topic/11057-cron-jobs/#findComment-41810 Share on other sites More sharing options...
poirot Posted June 4, 2006 Author Share Posted June 4, 2006 [!--quoteo(post=379984:date=Jun 4 2006, 11:32 AM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ Jun 4 2006, 11:32 AM) [snapback]379984[/snapback][/div][div class=\'quotemain\'][!--quotec--]you know..i was gonna say before, if a host doesn't offer the ability to run cron jobs... why bother even going with them?[/quote]Lack of Funds [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] Quote Link to comment https://forums.phpfreaks.com/topic/11057-cron-jobs/#findComment-41813 Share on other sites More sharing options...
nogray Posted June 5, 2006 Share Posted June 5, 2006 I found a few websites that offers alternative service to cron a while back, but I never tried them. you can search Cron Service on google to find more details. Here are two quick links[a href=\"http://www.fastcron.com/\" target=\"_blank\"]http://www.fastcron.com/[/a][a href=\"http://www.webbasedcron.com/\" target=\"_blank\"]http://www.webbasedcron.com/[/a] Quote Link to comment https://forums.phpfreaks.com/topic/11057-cron-jobs/#findComment-42188 Share on other sites More sharing options...
Buyocat Posted June 5, 2006 Share Posted June 5, 2006 Why not just add to the top of that page a simple line of code that says something like this...[code]$now = time();if ($now > $whenever) exit;[/code]for the whenever you can just use the time function add feed it some numbers:[a href=\"http://us3.php.net/time\" target=\"_blank\"]http://us3.php.net/time[/a] Quote Link to comment https://forums.phpfreaks.com/topic/11057-cron-jobs/#findComment-42202 Share on other sites More sharing options...
.josh Posted June 5, 2006 Share Posted June 5, 2006 yeah that's fine and dandy except that it requires the script to be accessed in order to do that. And if you were gonna do that, then there would be no point. Just access it whenever you need to. the point of cron jobs is that it's automated. Quote Link to comment https://forums.phpfreaks.com/topic/11057-cron-jobs/#findComment-42213 Share on other sites More sharing options...
poirot Posted June 5, 2006 Author Share Posted June 5, 2006 [!--quoteo(post=380399:date=Jun 5 2006, 03:48 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ Jun 5 2006, 03:48 PM) [snapback]380399[/snapback][/div][div class=\'quotemain\'][!--quotec--]yeah that's fine and dandy except that it requires the script to be accessed in order to do that. And if you were gonna do that, then there would be no point. Just access it whenever you need to. the point of cron jobs is that it's automated.[/quote]Exactly. And also, if you do this check everytime it access something that is scheduled to be executed every 24 hours, it's not good. Quote Link to comment https://forums.phpfreaks.com/topic/11057-cron-jobs/#findComment-42219 Share on other sites More sharing options...
maxim Posted June 20, 2006 Share Posted June 20, 2006 i have the same problem. i have a few scripts which generate a image. and out that image to a file.the file only gets updated when the script runs. My free host supports cron jobs.but im lost as to how to get it working. all tutorials i read say u need root acces or lynx which my host dose not have.any ideas on how to execute a PHP script form cron Quote Link to comment https://forums.phpfreaks.com/topic/11057-cron-jobs/#findComment-47589 Share on other sites More sharing options...
zq29 Posted June 20, 2006 Share Posted June 20, 2006 [!--quoteo(post=385929:date=Jun 20 2006, 11:10 AM:name=maxim)--][div class=\'quotetop\']QUOTE(maxim @ Jun 20 2006, 11:10 AM) [snapback]385929[/snapback][/div][div class=\'quotemain\'][!--quotec--]i have the same problem. i have a few scripts which generate a image. and out that image to a file.the file only gets updated when the script runs. My free host supports cron jobs.but im lost as to how to get it working. all tutorials i read say u need root acces or lynx which my host dose not have.any ideas on how to execute a PHP script form cron[/quote]If you don't have access to it through a GUI such as cPanel, you'd need to have SSH access to write the contab manually. Quote Link to comment https://forums.phpfreaks.com/topic/11057-cron-jobs/#findComment-47621 Share on other sites More sharing options...
maxim Posted June 20, 2006 Share Posted June 20, 2006 [!--quoteo(post=385968:date=Jun 20 2006, 09:34 PM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ Jun 20 2006, 09:34 PM) [snapback]385968[/snapback][/div][div class=\'quotemain\'][!--quotec--]If you don't have access to it through a GUI such as cPanel, you'd need to have SSH access to write the contab manually.[/quote]yeah i do have the access to the cPanel GIU and as it turns out it works ! here the entery into cron tab i made[code]00 * * * * php /home/MyUserName/public_html/script.php[/code]i belive it updates once every hour/day/week/year.how ever i test all my scripts localy before i upload themso when i put that crontab entry into my own local machines crontab it didnt work !see how i have the word "php" before the path to my script. what dose crontab do when it sees that ? Quote Link to comment https://forums.phpfreaks.com/topic/11057-cron-jobs/#findComment-47770 Share on other sites More sharing options...
rsj1 Posted June 20, 2006 Share Posted June 20, 2006 A great looking alternative to cronjobs would be [a href=\"http://www.dwalker.co.uk/phpjobscheduler/\" target=\"_blank\"]http://www.dwalker.co.uk/phpjobscheduler/[/a] I found this free script by accident earlier today when I was looking for an script to automatically backup my databases to server. I havn't tested it but it looks like it could do what you are asking ;) Quote Link to comment https://forums.phpfreaks.com/topic/11057-cron-jobs/#findComment-47786 Share on other sites More sharing options...
zq29 Posted June 20, 2006 Share Posted June 20, 2006 [!--quoteo(post=386124:date=Jun 20 2006, 08:18 PM:name=maxim)--][div class=\'quotetop\']QUOTE(maxim @ Jun 20 2006, 08:18 PM) [snapback]386124[/snapback][/div][div class=\'quotemain\'][!--quotec--]see how i have the word "php" before the path to my script. what dose crontab do when it sees that ?[/quote]The part where you have "php" is pointing to your install of php on the system, it looks like your host is set up to accept "php" as the path to php. If this is not working on your local machine, try pointing it to "usr/local/bin/php", I think thats the default install location (providing you're running a *NIX OS on your local machine. I am assuming you do as you said you have cron.)[!--quoteo(post=386140:date=Jun 20 2006, 09:29 PM:name=rsj1)--][div class=\'quotetop\']QUOTE(rsj1 @ Jun 20 2006, 09:29 PM) [snapback]386140[/snapback][/div][div class=\'quotemain\'][!--quotec--]A great looking alternative to cronjobs would be [a href=\"http://www.dwalker.co.uk/phpjobscheduler/\" target=\"_blank\"]http://www.dwalker.co.uk/phpjobscheduler/[/a] I found this free script by accident earlier today when I was looking for an script to automatically backup my databases to server. I havn't tested it but it looks like it could do what you are asking ;)[/quote]That still requires user interaction to trigger the script, automation without a scheduling application like cron or scheduler is impossible. Quote Link to comment https://forums.phpfreaks.com/topic/11057-cron-jobs/#findComment-47794 Share on other sites More sharing options...
rsj1 Posted June 20, 2006 Share Posted June 20, 2006 [!--quoteo(post=386148:date=Jun 20 2006, 10:32 PM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ Jun 20 2006, 10:32 PM) [snapback]386148[/snapback][/div][div class=\'quotemain\'][!--quotec--]That still requires user interaction to trigger the script, automation without a scheduling application like cron or scheduler is impossible.[/quote]Very true, but it looks like a great alternative to cron jobs if your host does not support them ;) Quote Link to comment https://forums.phpfreaks.com/topic/11057-cron-jobs/#findComment-47834 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.