1
我嘗試使solr在/etc/init.d/solr中作爲啓動腳本運行。 這是劇本,我從How to start Solr automatically?像守護進程運行solr
#!/bin/sh
# Prerequisites:
# 1. Solr needs to be installed at /usr/local/solr/example
# 2. daemon needs to be installed
# 3. Script needs to be executed by root
# This script will launch Solr in a mode that will automatically respawn if it
# crashes. Output will be sent to /var/log/solr/solr.log. A PID file will be
# created in the standard location.
# Comments to support chkconfig on Red Hat Linux
# chkconfig: 2345 64 36
# Description: A very fast and reliable search engine.
# processname solr
# Source function library.
. /etc/init.d/functions
start() {
echo -n "Starting solr..."
# start daemon
daemon --chdir='/usr/local/solr/example' --command "java -jar start.jar" --respawn --output=/var/log/solr/solr.log --name=solr --verbose
RETVAL=$?
if [ $RETVAL = 0 ]
then
echo "done."
else
echo "failed. See error code for more information."
fi
return $RETVAL
}
stop() {
# stop daemon
echo -n "Stopping solr..."
daemon --stop --name=solr --verbose
RETVAL=$?
if [ $RETVAL = 0 ]
then
echo "done."
else
echo "failed. See error code for more information."
fi
return $RETVAL
}
restart() {
daemon --restart --name=solr --verbose
}
status() {
# report on the status of the daemon
daemon --running --verbose --name=solr
return $?
}
case "$1" in
start)
start
;;
status)
status
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: solr {start|status|stop|restart}"
exit 3
;;
esac
exit $RETVAL
我所做的一切copypasted在上面的鏈接描述。但得到一個錯誤
service solr start
Starting solr.../etc/init.d/solr: Usage: daemon [+/-nicelevel] {program}
failed. See error code for more information.
閱讀https://blog.hazrulnizam.com/create-init-script-centos-6/我不明白爲什麼守護寫不正確