#!/bin/sh PIDFILE=/var/run/mysql/mysqld.pid echo "Processs ID file \$PIDFILE=$PIDFILE" echo echo "Ensuring mariadb is stopped..." sudo service mariadb stop echo "Show there's no PID file: " ls -l $PIDFILE echo echo "Start mariadb service..." sudo service mariadb start echo "The process id field exists, but it is not readable by an arbitrary user:" ls -l $PIDFILE # echo "And check it's contents:" # sudo cat $PIDFILE echo echo "Running 'service mariadb status' as root works:" sudo service mariadb status echo echo "But running it as other user fails:" service mariadb status echo echo "Manually fix the permissions..." sudo chmod o+r $PIDFILE ls -l $PIDFILE echo echo "Can read the file, but 'service mariadb status' still fails..." service mariadb status echo read DBPID < $PIDFILE echo "Process ID in $PIDFILE: $DBPID" echo "Try using the 'kill -0 $DBPID' command used by the the status option:" kill -0 $DBPID