I tried to to modify an existing script to work..the start option works fine. The "stop" option works ( it does kill the process successfully but gave some strange errors. Please see the output at the bottom. Can anyone please help?
#!/bin/sh
# ckconfig: 35 99 1
### BEGIN INIT INFO
# Provides: kibana
# Required-Start: $syslog $network $named $remote_fs $time networker
# Required-Stop: $syslog
# Should-Start: $ALL
# Should-Stop: $ALL
# Default-Start: 3 5
# Default-Stop: 0 6
# Description: Start the kibana application
### END INIT INFO
SCRIPT_NAME="$0"
SERVICE_NAME="kibana"
usage()
{
echo "USAGE: kibana start|stop" 1>&2
exit 1
}
start()
{
export kibana_exec="nohup /data/kibana-main/bin/kibana > /data/logs/kibana/kibana.log 2>&1 "
export kibana_parms="&"
if [ ! -f $kibana_exec ]; then
echo "kibana ERROR"
RETVAL=1
return 1
fi
/bin/su - Delk_admin_dev -c "$kibana_exec $kibana_parms 2>&1"
RETVAL=$?
return $RETVAL
}
stop()
{
export PIDFILE="`(ps -eaf | grep kibana | awk '{print $2}')`"
export pid=$PIDFILE
if [ ! -f $kibana_exec ]; then
echo "kibana ERROR"
RETVAL=1
return 1
fi
/bin/su - Delk_admin_dev -c "kill -15 $pid"
RETVAL=$?
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
*)
/bin/echo $"Usage: kibana {start|stop}"
;;
esac
exit $?
[Delk_admin_dev@pvmdlr001 ~]$ ./newbash stop
./newbash: line 39: [: too many arguments
Password:
-bash: line 1: 8197: command not found
pgrep
might be better thanps | grep
. edited. – ilkkachu May 30 '17 at 18:59