NameSilo

Run a PHP script every hour?

Spaceship Spaceship
Watch

cbr600

Account Closed
Impact
0
Hey,

Im writing an imagehosting script and need to reset the bandwith every hour. I could write a script that queries the database, but how can I have it run every hour?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
.US domains.US domains
You could use a cron entry to run every hour a script. If you have a CPanel hosting account, click the "crontab" link, and follow the guidelines...
 
0
•••
Yeah, cron jobs is your best option, unless you want to do it automatically! :P
 
0
•••
Thanks for the replies,


I've heard of cronjobs mentioned before, so I'll look into that. Thanks
 
0
•••
All I can think of is using a cronjob, unless you want to run a script yourself hourly or your site recives more than 1 hit an hour, if so, then you could do it by checking the time of the last run in some kind of storage (textfile? db), and the current time. If more than an hour has passed, do the operation

(sorry not that good at php coding myself... so I can only think of how to do it in English :) )
 
0
•••
Masahiro said:
All I can think of is using a cronjob, unless you want to run a script yourself hourly or your site recives more than 1 hit an hour, if so, then you could do it by checking the time of the last run in some kind of storage (textfile? db), and the current time. If more than an hour has passed, do the operation

(sorry not that good at php coding myself... so I can only think of how to do it in English :) )

you are 100% correct.. it would be the best thing to do if cron is not available. I was doing like that with my first site when I had a host without cronjobs.
 
0
•••
idk if this wud work, but i guess you could put a javascript code on the page so that it autorefreshes every hour; so that when it refreshes, the code is executed again. of course, you would have to leave open the window on your computer so that it WOULD autorefresh.
 
0
•••
cron job best option i think
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back