我曾经用这个命令启动Solr:
java -jar start.jar
而我所要做的就是停止按Control + C
但后来我这样开始了:
java -jar start.jar &
它作为一个后台进程启动,所以我可以在启动后返回shell。 但是现在我不知道如何阻止它。 我正在使用Ubuntu服务器。
你开始了这个过程并把它放在后台。 使用jobs命令列出后台进程。
要将后台进程置于前台,请使用fg [job number] 。 从那里,你可以像平常一样退出。
根据新的信息,这个问题与前景和后台过程无关。 显然这个过程正在后台启动,然后terminal窗口closures。 因此,terminal不再是terminal的工作。
在这种情况下,您只需要终止与Solr相关的进程。 使用ps来查找进程并kill以停止它。
创build一个deamon,根据你的需要修改path。
在这里input代码将SOLR作为守护程序安装的步骤
create /etc/init.d/solr.production and copy the below contents into the file. Please change all necessary paths. change directory to /etc/init.d run sudo /sbin/chkconfig --add solr.production run sudo /sbin/service solr.production start run ps -Af | grep start.jar to check that it is running run cat /var/run/solr.production.pid (change path if needed) to see if PID value is correct.
/etc/init.d/solr.production
#!/bin/bash # chkconfig: 2345 98 02 # description: Starts and stops Solr production # source function library . /etc/rc.d/init.d/functions set -e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin SOLR_HOME=/var/apps/solr PIDFILE=/var/run/solr.production.pid START_COMMAND="/usr/lib/jdk1.6.0_03/bin/java -Xms512M -Xmx1024M -jar start.jar" LOG_FILE="$SOLR_HOME/logs/console.log" NAME="Solr (production)" start() { echo -n "Starting $NAME" if [ -f $PIDFILE ]; then echo -n "$PIDFILE exists. $NAME may be running." else cd $SOLR_HOME $START_COMMAND 2 > $LOG_FILE & sleep 2 echo `ps -ef | grep -v grep | grep "$START_COMMAND" | awk '{print $2}'` > $PIDFILE echo "Done" fi return 0 } stop() { echo -n "Stopping $NAME" kill `cat $PIDFILE` rm $PIDFILE echo "Done" return 0 } case "$1" in start) start ;; stop) stop ;; restart) stop sleep 5 start ;; *) echo "Usage: $0 (start | stop | restart)" exit 1 esac exit $?
现在你可以使用/etc/init.d/solr stop | start | restart
我从lucidWorks / app / bin / stop.sh得到了这个,希望对你有用
#!/usr/bin/env bash # You can override pass the following parameters to this script: # -lwe_app_dir -lwe_data_dir -lwe_conf_dir -lwe_log_dir JVM="java" # Find location of this script and go up a level to lucidworksAppHome sdir="`dirname \"$0\"`" # Stop the processes $JVM -jar "$sdir/StartUtil.jar" -jvm_cmd $JVM ${1+"$@"} stop