Executing a PHP script every few seconds

Open /etc/crontab with VI and add lines similar to the ones seen below. Make sure to use <tab> instead of spaces!

* * * * * root php /your/file/location.php > /dev/null 2>&1
* * * * * root sleep 10; php /your/file/location.php > /dev/null 2>&1
* * * * * root sleep 20; php /your/file/location.php > /dev/null 2>&1
* * * * * root sleep 30; php /your/file/location.php > /dev/null 2>&1
* * * * * root sleep 40; php /your/file/location.php > /dev/null 2>&1
* * * * * root sleep 50; php /your/file/location.php > /dev/null 2>&1

 

Restart cron deamon using the command show in this post.

Back to Top