• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Issue Nginx not starting after reboot

Alireza Famili

Basic Pleskian
I rarely ever restart my server, but just in case.....
I have this watchdog which starts nginx (or some other service) whenever it's not running.
Because I don't want to write a different watchdog for each server I wrote something that should work in most cases by just using the name of the service in the symbolic link.

My watchdog is working for
Code:
watch-mysql
watch-nginx
watch-redis-server
watch-zabbix-agent
watch-syncthing
watch-rslsync

grep cron.5min /etc/crontab
Code:
*/5  *  *   *   * root   cd / && run-parts /etc/cron.5min

cat /usr/local/sbin/watch-process
ln -s /usr/local/sbin/watch-process /etc/cron.5min/watch-nginx
Code:
#!/bin/bash

PROCESS="`echo $0 | grep -o 'watch-.*' | cut -b7-`"
THIS_SCRIPT="`readlink $0`"
SCRIPTNAME=${THIS_SCRIPT##*/}

if [ -z "${PROCESS}" ] ; then
  echo "Wrong usage: make a symbolic link to ${THIS_SCRIPT} named watch-<service>" >&2
  exit 1
elif [ "watch-${PROCESS}" = "${SCRIPTNAME}" ]  ; then
  echo "Wrong usage: make a symbolic link to ${THIS_SCRIPT} named watch-<service>" >&2
  exit 1
fi

USER="`echo ${PROCESS} | awk -F- '{print $1}' | cut -b1-7`"
USERID="`grep "^${USER}" /etc/passwd | awk -F: '{print $3}'`"
SEARCH="`echo ${PROCESS} | tr - .`"
SERVICE=`find /etc/init.d/ -maxdepth 1 -type f | grep ${SEARCH} | head -n1`

if ! grep -q ${USER} /etc/passwd ; then
  echo "${USER} does not exist, service is not installed" >&2
  exit 1
fi
if [ -z "${SERVICE}" ] ; then
  echo "${SERVICE} is not installed as service" >&2
  exit 1
elif [ ! -x ${SERVICE} ] ; then
  echo "${SERVICE} is a DISABLED service" >&2
  exit 1
fi

ps aux | egrep "^(${USER}|${USERID} )" | grep -q " .*${SEARCH}" && exit 0

echo "`date +%b' '%d' '%H:%M:%S` Watchdog $0 invokes \"${SERVICE} start\"" | tee -a /var/log/${SCRIPTNAME}.log >&2

${SERVICE} start
 
Back
Top