Time-Triggered PHP

SpaceshipSpaceship
Watch

Zurvan

Established Member
Impact
13
I have no idea if this is even possible.

I have a function (that works) that I would like to trigger at Midnight, every day. Is it possible to do something like this?

I really have no idea where to start looking, I'm hoping somebody can help out.

Thanks in advance.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Set up a cron job if you are on a Linux machine. You cannot do this in straight PHP.

-Bob
 
0
•••
moondog said:
Set up a cron job if you are on a Linux machine. You cannot do this in straight PHP.

-Bob

there are also schedualers in windows (i think "at" is one)



Zurvan - To Run a job at a certian time everyday, there's 2 ways you can do it, 1) use the Operating system to do it (via cron on *nix system, or at on windows)
2) Setup a php file that is loaded as an image, uses a table to store the last time it was run, if it hasn't been run that day, and it's past midnight, do the run (this might not happen to 6 in the morning, but if nobody has visited the site that might be ok)
 
0
•••
Depends on which system you are, but given you are on a Unix system you can use cron as it was already suggested by others.

In your case you would need "0 0 * * * myscript.php"
 
0
•••
i think its directly possible in php but that would require a flat file database (txt file) to check when the script was run. if the time is 12 then it should do its task otherwise it should die.. u can start the script by using those online host-uptime checkers who check for the servers every 1hour or so
 
0
•••
Thanks everyone. It's a *NIX server, so we can use cron.
 
0
•••
champ_rock said:
i think its directly possible in php but that would require a flat file database (txt file) to check when the script was run. if the time is 12 then it should do its task otherwise it should die.. u can start the script by using those online host-uptime checkers who check for the servers every 1hour or so
I've used this method before, sorta how like vBulletin does theirs; use a cron.php file (when accessed, outputs a 1x1 pixel image), included on all pages:
HTML:
<img src="cron.php" />

Good solution if you can't use crontab.
 
0
•••
Dynadot — .com TransferDynadot — .com Transfer
Appraise.net

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back