Shell Script to check openoffice as service linux

OpenOffice

Use crontab to schedule the script

0 0 * * * /opt/scripts/checkoo.sh [email protected] /Path/To/Openoffice/Installation/"program"/folder/ > /dev/null

Above command is to run the satus everyday at midnight, depending on how frequent the service goes down you can schedule it to run , like each hour or each 30minutes etc.
Add the script to crontab by crontab -e
Here OpenOffice service port number is taken as 8100

 #!/bin/sh
 export EDITOR=/bin/vi
 export DISPLAY=localhost:11.0
 _Up=`ps -eaf | grep soffice | grep -v grep | awk '{print $NF}'\;`
 _Up1=`netstat -an | grep 8100 | grep -v grep | awk '{print $4" "$6}'\;`
 _Up2=`find /tmp/ -name "null" -daystart -ctime +1`
 _Up3=`cat /tmp/null | wc | awk '{print $1}' ;`
 #echo "${_Up3}"
 if [[ "${_Up}" = "" ]]
 then
 # touch /tmp/null;
 date>> /tmp/null;
 echo "Open Office process soffice is not running">> /tmp/null;
 if [[ "${_Up1}" = "" ]]
 then
 echo "Open office is not Listening on port 8100">> /tmp/null;
 mail -s "Open Office Status Report" $1 < /tmp/null;
 ########################################################################################
 ##################################Starting OpenOffice Automatically####################
 ########################################################################################
 # echo "${2}"
 cd ${2}
 ./soffice -invisible -"accept=socket,host=0,port=8100;urp" &
 # kk=`./soffice -invisible -"accept=socket,host=0,port=8100;urp" &`
 # echo "${kk}" >> /tmp/null
 else
 date>>/tmp/null;
 echo "script is not running properly..Unable to fetch Open Office status">>/tmp/null;
 mail -s "Open Office Status Report" $1 < /tmp/null;
 fi
 else
 # touch /tmp/null
 date>> /tmp/null;
 echo "Open Office is running and Listening on Port 8100" >> /tmp/null;
 # echo "open office running";
 mail -s "Open Office Status Report" $1 < /tmp/null;
 fi
 #if [[ "${_Up2}" != "" ]]
 if [[ "${_Up3}" -ge "70" ]]
 then
 mail -s "OpenOffice_Full_Day_Status_Report" $1 < /tmp/null;
 # find /tmp/ -name null -daystart -mtime +1 -exec rm -rf {} \;
 mv /tmp/null /tmp/nullbkup;
 date > /tmp/null;
 echo " Removed the 7+days old Status report and Starting a new status report for next seven days" >> /tmp/null;
 else
 exit;
 fi

In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.

1 Response

  1. systemy erp says:

    Way cool! Some extremely valid points! I appreciate
    you penning this write-up and also the rest of the site is very
    good.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.