Linux service restart shell script Rumi, June 6, 2014 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 Configurations (Linux) Scripts LinuxShell
How to Upgrade Node.js via NPM August 23, 2017 Steps to Upgrade Node.Js Use the following steps to install or upgrade node.js to latest available version. Current NodeJs Version – First check current nodejs version on your system using following command. In my case it is v0.10.37.rahul@tecadmin:~$ node -v v0.10.37 Clean Cache Forcefully – Now clean all npm cache from your… Read More
Install XRDP in Debian 9 August 8, 2018 Install XRDP and TigerVNC server $ sudo apt install -y xrdp tigervnc-standalone-server Connect XRDP from Windows 10 Windows start button -> Windows Accesssories -> Remote Desktop Connection Input FQDN or IP address of XRDP server and connect to XRDP. XRDP RDP terminal will appear. Select “XVNC” Session and connect. … Read More
Let’s Encrypt service with Pound server February 5, 2018 In order to install Certbot on your server, follow the next steps: (make sure you have “git” installed on your system) $sudo apt-get install git (if not previously installed) $cd /opt $sudo git clone https://github.com/certbot/certbot Running the above commands will download the Certbot latest release from their git repo in… Read More