Affichage des articles dont le libellé est bash. Afficher tous les articles
Affichage des articles dont le libellé est bash. Afficher tous les articles
mercredi 23 août 2017
Monitoring application with a simple bash under linux
Edit a cron file
vi /etc/cron.hourly/monitorhttpd.sh
#!/bin/bash
ps -ef |grep `cat /var/run/httpd/httpd.pid`|grep httpd>/tmp/httpjenkinscount
NBPCS=`wc -l
if [ "$NBPCS" -eq "0" ]; then
service httpd start
fi
#!/bin/bash
ps -ef |grep `cat /var/run/tomcat-jenkins/tomcat.pid`|grep java>/tmp/tomcatjenkinscount
NBPCS=`wc -l
if [ "$NBPCS" -eq "0" ]; then
sudo -ujenkins -- "/local/home/jenkins/tomcat-7/bin/shutdown.sh"
sleep 30
rm -f /var/run/tomcat-jenkins/tomcat.pid
sudo -ujenkins -- "/local/home/jenkins/tomcat-7/bin/startup.sh"
fi
But you can also perform some more complex monitoring by testing call to url (end to end test)
vi ./autorestartscript.sh
#!/bin/sh
rm -f /tmp/status
wget https://myserver/myapp/status --no-check-certificate -O /tmp/status
RETOUR=$?
KOCOUNT=`cat /tmp/status|grep KO|wc -w`
if [ $KOCOUNT -ge 1 ] || [ $RETOUR -ge 1 ];
then
service tomcat6_myapp stop;
sleep 30
service tomcat6_myapp start;
service httpd_myapp restart;
fi
mercredi 24 mai 2017
Automatical periodic backup with simple bash script
Here is a very basic way to create a periodic backup of some of your folder in a LINUX environment
Create an cron file /etc/cron.montlhy/backup-tomcat
#!/bin/sh
SCOPE=monthly
tar -cvzf /mnt/nas/backup-tomcat/tomcat-`date +%Y%m%d`-$SCOPE.tgz -C/home/clement tomcat-8
find /mnt/nas/backup-tomcat/ -name \*$SCOPE\* -mtime +365 -exec rm -f {} \;
Inscription à :
Articles (Atom)