service jbossas status -> command will check the jbossas status
jbossas(PID) is running (if jbossas is running)
jbossas is stopped (if jbossas is stopped)
#!/bin/ksh #set -x OUT_LOG="$1" stus=$(service jbossas status) var=$(ps -ef | grep -i '[/]jboss') hname=$(hostname) if [ -z "$var" ]; then echo "service jbossas status" >>$OUT_LOG echo "$stus" >>$OUT_LOG mail -s "Please check for possbile impact $(stus)" firstname.lastname@example.org << $OUT_LOG else echo "'$stus'" fi
NOTE:JBOSS process is not running on server so the o/p will be jboss is stopped .
If i execute the script manually in the shell(balck screen cmd prompt)
Im receiving the mail with below subject and script is working fine
"Please check for possible impact jbossas is stopped"
but when i schedule it in the cron
* * * * * /aaa/jboss_status.ksh > /aaa/jboss_status.ksh.error 2>&1
Im receiving the mail with below subject "Please check for possbile impact" NOTE :"jbossas is stopped " is not getting printed at end of the subject
In getting below error in the error file created by cron
/aaa/jboss_status.ksh: service: not found [No such file or directory]
The script is executing fine in cron but the output returned by the
command : service jbossas status op: jboss stopped
is not getting printed in the subject