FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Repetitive Events Without Cron Jobs





polly-gone
Hey guys, I have a quick question for you all...

What is the best way to make a script run at a set time everyday without having to use Cron jobs? For example, newer versions of phpBB can automatically delete older posts once they are past a certain threshold that the user sets (i.e. 10 days, 30 days, 60 days, whatever), but its not utilizing a cron job. What is the best way to go about running a repetitive event without having to dive into a websites admin panel?

Thanks ahead of time,

-Nick Smile Smile Smile
riccopt
polly-gone wrote:
For example, newer versions of phpBB can automatically delete older posts once they are past a certain threshold that the user sets (i.e. 10 days, 30 days, 60 days, whatever), but its not utilizing a cron job.

if that was true you if one user sets his account to one day all psts would be lost on the next day...
what that does is a SQL query that will only get the posts from a certain range... it has nothing to do with CRON JOB... it is a simple QUERY that will parse the proper results on the screen...

there are certain ways to EMULATE a cron job... but it is not as good as running a cronjob...
polly-gone
No, I meant the phpBB user, not the forum user. The administrator can set when a range when all old posts are to be deleted. That is a sql query that removes all the old posts from the database. I want to know how it knows to run daily and delete all posts over the date threshold.

-Nick Rolling Eyes Rolling Eyes Rolling Eyes
snowboardalliance
polly-gone wrote:
No, I meant the phpBB user, not the forum user. The administrator can set when a range when all old posts are to be deleted. That is a sql query that removes all the old posts from the database. I want to know how it knows to run daily and delete all posts over the date threshold.

-Nick Rolling Eyes Rolling Eyes Rolling Eyes


It's been a while since I've looked at the phpBB source but the simple way is to have some database entry like "last_check" and set it to the current time, then every page load, if the last check is older than some time (say a few hours depending on the granularity required) then run the script that deletes the old posts and update the "last_check"

If you need more advanced cron emulation, there is a lot of stuff already out there. I think basically it works by running the "cron job" x times when the page loads, based on the last time the page was loaded. So if the job should run every hour, it would run the job, then it would only run the job again if it had been an hour since the last run. If it has been 4 hours since the job has run, it will run 4 times. I think that is the basic concept because it will have the same end effect (in general) because the changes done by cron wouldn't have been apparent until there was a pageview. With enough traffic, it would run as often as a cron job. Definitely need checks to not run the script simultaneously so that runs do not get duplicated. Anyway, this work has been done for you if you find the right php scripts online.
Disclaimer, I have not used these scripts, only read into it a little bit and made some inferences[/i]
Related topics
Cron Jobs
propos des cron jobs
[RESOLVED] cron jobs
Cron jobs
I don't have cron jobs enabled ?
cron jobs
Cron Jobs
Cron Jobs
Cron Jobs
Cron jobs - running a php file
Executing automated tasks without using cron jobs
cron jobs?
Problems With Cron Jobs
Enabling Cron Jobs
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.