TrzasQ TrzasQ - 3 months ago 6
Linux Question

loop php script in bash

I need to run php cli every second in linux bash.
Below you can find my windows.bat file:

:loop
start /b pathTophp.exe pathTo\cycler.php
timeout /t 1
goto loop


Perhaps I can use cron and run this simple script every second but I assume minute is a least interval.

#!/bin/bash
php56 cycler.php


As I know there is no goto in bash and I don't know bash at all. So how can I make this?

Answer

you are correct cron can only go to 1 minute interval, try this

#!/bin/bash
while true
do 
 php56 cycler.php
 sleep 1
done

this will loop until you stop it with ctrl-c

Comments