How to keep a job running in Linux

There are many ways to keep a process running on linux but I haven’t seen any that are as easy to implement as the script below.

Basically the script does a ps ax and then a grep for your process. If it’s not running it will re-start the process.

You install the script into your crontab i.e. crontab -e

As a bonus this mechanism will re-start your process after a re-boot. Continue reading “How to keep a job running in Linux” »


CRON scripts to running in seconds interval


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:
#Desc:Run script in every 20 seconds
while (sleep 20 && php /path_to_your_script/your_script_name.php) &
wait $!
Then, make script executable, and add it to the system startup. That’s all.