Skip to content
Advertisement

Run a PHP file every 5 seconds using Shell Script

I want to run a php file every 5 seconds using Shell Script. But sometimes the script gets run every second or sometimes gets stop running. Do I need to use crontab also? Please help.

JavaScript

Advertisement

Answer

The best thing would be to configure crontab to keep the execution or another program installed as a service.

The problem with contrab is that the minimum execution is every 1 minute. Therefore, you should create a script that executes every 5 seconds no more than 12 times. (12 x 5 seconds = 60 seconds)

Kill the process and re-run it with crontab.

Example

sript.sh

JavaScript

On crontab

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement