Linux service restart shell script Rumi, November 29, 2013November 29, 2013 I badly needed a script that would check if my running services (in this script it'll check varnish and apache2 services) are alive- if not, it'll restart the dead service and write a log. Pretty handy! #!/bin/sh STARTAPACHE="/etc/init.d/apache2 start" STARTVARNISH="/etc/init.d/varnish start" LOGFILE=/var/log/service_uptime.log ################ Check Varnish ################# SERVICE='varnish' echo "" >> $LOGFILE echo `date` >> $LOGFILE if ps ax | grep -v grep | grep $SERVICE > /dev/null then echo "$SERVICE service running, everything is OK" >> $LOGFILE else echo "$SERVICE is not running, restarting $SERVICE" >> $LOGFILE checkvarnish=`ps ax | grep -v grep | grep -c varnish` if [ $checkvarnish -le 0 ] then $STARTVARNISH if ps ax | grep -v grep | grep $SERVICE > /dev/null then echo "$SERVICE service is now restarted, everything is OK" >> $LOGFILE fi fi fi ############### Check Apache ################ SERVICE='apache2' if ps ax | grep -v grep | grep $SERVICE > /dev/null then echo "$SERVICE service running, everything is OK" >> $LOGFILE else echo "$SERVICE is not running, restarting $SERVICE" >> $LOGFILE checkapache=`ps ax | grep -v grep | grep -c apache2` if [ $checkapache -le 0 ] then $STARTAPACHE if ps ax | grep -v grep | grep $SERVICE > /dev/null then echo "$SERVICE service is now restarted, everything is OK" >> $LOGFILE fi fi fi exit 0 Related Administrations Scripts Service RestartShell
Install Memcache November 11, 2012June 20, 2013 By default PHP loads and saves sessions to disk. Disk storage has a few problems: 1. Slow IO: Reading from disk is one of the most expensive operations an application can perform, aside from reading across a network. 2. Scale: If we add a second server, neither machine will be… Read More
Configuring SpamAssassin for Postfix on CentOS May 23, 2020 In the process of receiving email, spamassassin will stand between the outside world and the email services running on your server itself. If it finds, according to its definition rules and configuration, that an incoming message is spam, it will rewrite the subject line to clearly identify it as such…. Read More
SOLVED Debian Wheezy Letsencrypt error /opt/eff.org/certbot/venv/bin/python: No module named pip.__main__; ‘pip’ is a package and cannot be directly executed May 10, 2019 My case and solution: Debian 7.11 wheezy python2.7 python-pip NOT installed My steps: #ln -fs /usr/lib/python2.7/plat-x86_64-linux-gnu/_sysconfigdata_nd.py /usr/lib/python2.7/ #wget https://raw.githubusercontent.com/certbot/certbot/75499277be6699fd5a9b884837546391950a3ec9/certbot-auto #chmod +x ./certbot-auto #certbot-auto renew –no-self-upgrade it download some files and works fine. Src: https://github.com/certbot/certbot/issues/6824 Related Read More