How to run scripts in Linux faster than Cron does

Cron is an amazing job scheduler. But, when it comes to running your scripts in less than every minute, it can’t help.

With Cron, you can run your scripts every minute, but not in shorter period of time.

This problem can be solved with simple bash script. For example, if you need to run a PHP script on every 20 seconds, you can create a bash script like this:

#!/bin/bash
#Name:myscript.sh
#Desc:Run script in every 20 seconds
while (sleep 20 && php /path_to_your_script/your_script_name.php) &
do
 wait $!
done

Then, make script executable, and add it to the system startup. That’s all.

 

 


If you liked the post, we should get connected - follow me on Twitter