Script to check if Website alive and restart Services if necessary

I was looking into a LAMP Server these days and had one effect that some pages became unresponsive over time. While the Error was not easy to detect and fix we decided to create a check script to check a certain URL and in case of a timeout server services would be restarted automatically. Not the bast possible way but maybe the most straight forward one.

Please adjust the service commands on the top to have the right restart commands inside.

#! /usr/bin/bash
function restart {
service nginx restart
service mariadb restart
service httpd restart

function check {
if [ $? -ne 0 ] ; then
echo "Error occurred getting URL $1:"
if [ $? -eq 6 ]; then
echo "Unable to resolve host"
if [ $? -eq 7 ]; then
echo "Unable to connect to host"
exit 1


Call for this script looks like…


Cron like

*/15 * * * * /scripts/

MYSQL Long kill long Querys via Script in Cron

As part of my private life i sometimes help friends with their Webservers. Recently i had a case of a LAMP Server including Maria / MySQL DB. Some Queries lasted “forever” in the DB and consumed a lot of CPU. I created small script which looks into the DB and kills thoos querys.

This Script was done for a Server where the Password of MySQL is stored in a File (Plesk) Therefore the -p Command contains a cat of the password. Please adjust the script to take the right username and password.

# Kill long Mysql Queries
mysql -uadmin -p`cat /etc/psa/.psa.shadow` -ANe"SELECT id FROM information_schema.processlist WHERE time > 360;" | cut -d: -f2 |\
while read id
mysql -uadmin -p`cat /etc/psa/.psa.shadow` -ANe"kill $id;"

Cron looks like this to check this all 10 minutes and not receive any notification about it.

*/10 * * * * /root/ >/dev/null 2>&1

Synology DSM6 external USB Disk issue

Synology DSM6 external USB Disk issue

After updating my Synolog DS216play to DSM6 i had issues with my external USB3.0 Drive which i use for Backups. It was no longer detected. After opening a Support Case and some forward and backward emails they team has implemented a solution.
They created a task in the task planer which runs on bootup by root and does execute this code:

rmmod dwc3-st.ko;
sleep 3;
rmmod phy-st-usb3.ko;
sleep 1;
insmod /lib/modules/phy-st-usb3.ko miphy_ssc_off=1;
insmod /lib/modules/dwc3-st.ko;


Then i had to execute this actions.

  1. Shut down 216play and plug out storage (USB cable and USB power cable) so it’s powered off completely
  2. Wait for at least 1 minute
  3. Boot 216play
  4. plug in storage (USB cable and USB power cable)

Now its working fine again.