Run a PHP script once a minute

I need to execute my PHP code every minute. Is there any way to do this?

+6
php scheduled-tasks
source share
3 answers

You can run the PHP code from the command line. for example, if your PHP folder is in PATH:

php.exe C:\mycode\myfile.php 

You can then set this as a scheduled task on Windows. Side notes: keep in mind that some things do not exist (and something exists in their place), for example. Apache or IIS, as well as the full range of HTTP materials.

+9
source share

Configure cron .

+6
source share

If you do not want to use cron; you can write a script to call it at the top of the minute

 #!/bin/bash while [ true ]; do if [ $(expr $(date +%s) % 60) -eq 0 ]; then echo "top o da minute"; #put PHP  here fi; sleep 1; done 

The advantage / disadvantage is that you only create one copy of the script if it takes more than a minute.

+2
source share

All Articles