2 solutions pour gérer la notion de temps :
1) Dans : /foo/bar/script.php
<?php
function execute() {
// ton code
}
while(true) {
execute();
shell_exec("php /foo/bar/script.php");
sleep(1);
}
Et tu lances le script php (voir plus bas)
2) Dans /foo/bar/script.sh
- !/bin/sh
while true; do php /foo/bar/script.php; sleep 1; done
Dans : /foo/bar/script.php
<?php
function execute() {
// ton code
}
execute();
Et tu lances le script shell (voir plus bas)
Pour lancer les commandes sans être contraint de laisser un terminal ouvert :
1) avec "screen"
$ screen -S monscript
php /foo/bar/script.php
ou
$ screen -S monscript
/foo/bar/script.sh
Tu pourras récupérer le prompt via : screen -Dr monscript
2) Utiliser nohup :
$ nohup php /foo/bar/script.php >/dev/null 2>&1 &
ou
$ nohup /foo/bar/script.sh >/dev/null 2>&1 &