Cron job throwing error "service: not found [No such file or directory]" but when executed manually in terminal script works fine
1
vote
2
answers
1523
views
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)" aaa@aaa.com /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
Asked by star
(173 rep)
Nov 19, 2016, 08:58 AM
Last activity: Sep 27, 2017, 09:55 PM
Last activity: Sep 27, 2017, 09:55 PM