Are you getting this error on your WordPress website?

“error establishing database connection”


Create a file with this code :

UP=$(/etc/init.d/mysql status | grep running | grep -v not | wc -l);
if [ "$UP" -ne 1 ];
echo "MySQL is down.";
service mysql start

echo "All is well.";

$ chmod +x
$ crontab -e

One file will open after running the above command. Now, you just add the below line at the end of the file and after that save it.

*/5 * * * * /<path>/

If you are getting this error :

“fi” unexpected (expecting “then”) in shell scripts

then you have to convert the file with dos to unix converter. I have used one online:

Useful links :