-1
Someone has a simple example of a timer on PHP, to call a function at each predetermined time. For example, to check if a certain time or date/time has already arrived.
-1
Someone has a simple example of a timer on PHP, to call a function at each predetermined time. For example, to check if a certain time or date/time has already arrived.
1
You can make use of the crontab
, just set the time and the file php
what to call; for example:
* * * * * root php /path/file.php >/dev/null 2>&1
This script will run every minute, and every day, by the root user, below I will leave a self explanatory image of the use of cromtab;
The
>/dev/null 2>&1
plays all the way out of limbo, simple way of not printing on the screen returns from the script.
There are other ways to use, for example with Laravel;
One observation: if that is the answer, the question is duplicated. There are already several on the site talking about crontab and task scheduler (note that the question has been abandoned since 2016).
Yes I realized after responding, I saw that Avia been updated today, with respect to crontab I see no more practical form than this.
Browser other questions tagged php timer
You are not signed in. Login or sign up in order to post.
Post the code you’ve done so far!
– stderr
Depending on your goal it is not possible, as PHP needs a trigger to run. Because without running a script a script does nothing, it would need the timer to be done either in crontab, or with javascript. Why in pure PHP would need refresh to check the weather
– Leonardo
Could you better contextualize your question?
– Allan Andrade
It depends, you want to run something in the background, or you want when the time comes, php to send something to the browser?
– mau humor
It is for several functions, such as updating a date/time, mounting a countdown counter, checking if the database has been changed.
– Orlando FMC
@Orlandofmc which server ?
– Bulfaitelo