linux_fedora nexus_auto_start

8501 ワード


fedora 20はrcではありません.localサポートは、実はrcを削除しただけです.localファイルは、電源を入れるときに自分で書いたスクリプトを実行したい場合は、rcを新規に作成します.localファイルでいいので、テストしてみましょう.
環境:fedora 20 GNOMEデスクトップ
1./etc/rc.localは実は/etc/rcです.d/rc.localのソフト接続では、次のようにします.
vi /etc/rc.d/rc.local
 1 #!/bin/bash
 2 #this is a script foe nexus start,if the nexus is startting,return.
 3 echo "nexus verify.."
 4 testing8081=`(netstat -an|grep 8081)`
 5 if [ "NULL$testing8081" = "NULL" ] ; then
 6         echo "nuxus starting..."
 7         /home/Jorcen/Environments/nexus/nexus-2.7.0-04/bin/nexus start
 8        else
 9         echo -n "nexus had started,do you need restart it?(Y/N):"
10         read verify
11         if [ "$verify" = "Y" ] ; then
12                 /home/Jorcen/Environments/nexus/nexus-2.7.0-04/bin/nexus restart
13         echo "nexus restared.."
14         fi
15 fi

ファイル/lib/systemd/system/rc-localを編集します.サービス、ConditionFilel**ecutable=/etc/rc.d/rc.local前賞番号注記および#ConditionFilel**ecutable=/etc/rc.d/rc.local
[root@localhost Jorcen]# vi /lib/systemd/system/rc-local.service

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.d/rc.local is executable.
[Unit]
Description=/etc/rc.d/rc.local Compatibility
#ConditionFileIsExecutable=/etc/rc.d/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.d/rc.local start
TimeoutSec=0
RemainAfterExit=yes
SysVStartPriority=99

 step2
 1 [root@localhost Jorcen]# chmod +x /etc/rc.d/rc.local
 2 [root@localhost Jorcen]# ln -s /etc/rc.d/rc.local /etc/rc.local
 3 [root@localhost Jorcen]# systemctl status rc-local.service
 4 rc-local.service - /etc/rc.d/rc.local Compatibility
 5    Loaded: loaded (/usr/lib/systemd/system/rc-local.service; static)
 6    Active: failed (Result: exit-code) since Sat 2014-03-08 00:14:13 CST; 2min 44s ago
 7   Process: 2397 ExecStart=/etc/rc.d/rc.local start (code=exited, status=203/EXEC)
 8 
 9 Mar 08 00:14:13 localhost.localdomain systemd[1]: Starting /etc/rc.d/rc.local...
10 Mar 08 00:14:13 localhost.localdomain systemd[1]: rc-local.service: control p...
11 Mar 08 00:14:13 localhost.localdomain systemd[1]: Failed to start /etc/rc.d/r...
12 Mar 08 00:14:13 localhost.localdomain systemd[1]: Unit rc-local.service enter...
13 [root@localhost Jorcen]# systemctl start rc-local.service
14 [root@localhost Jorcen]# systemctl status rc-local.service
15 rc-local.service - /etc/rc.d/rc.local Compatibility
16    Loaded: loaded (/usr/lib/systemd/system/rc-local.service; static)
17    Active: active (running) since Sat 2014-03-08 00:17:26 CST; 27s ago
18   Process: 2481 ExecStart=/etc/rc.d/rc.local start (code=exited, status=0/SUCCESS)
19  Main PID: 2541 (wrapper)
20    CGroup: name=systemd:/system/rc-local.service
21            ├─2541 /home/Jorcen/Environments/nexus/nexus-2.7.0-04/bin/jsw/linux-x86-64/wrapper /home/Jorcen/Environments/nexus/nexus-2.7.0-04/bin/js...
22            └─2543 java -Djava.net.preferIPv4Stack=true -Dcom.sun.jndi.ldap.connect.pool.protocol=plain ssl -Djava.library.path=bin/jsw/lib -classpa...
23 
24 Mar 08 00:17:26 localhost.localdomain systemd[1]: Starting /etc/rc.d/rc.local Compatibility...
25 Mar 08 00:17:26 localhost.localdomain rc.local[2481]: nexus verify..
26 Mar 08 00:17:26 localhost.localdomain rc.local[2481]: nuxus starting...
27 Mar 08 00:17:26 localhost.localdomain rc.local[2481]: ****************************************
28 Mar 08 00:17:26 localhost.localdomain rc.local[2481]: WARNING - NOT RECOMMENDED TO RUN AS ROOT
29 Mar 08 00:17:26 localhost.localdomain rc.local[2481]: ****************************************
30 Mar 08 00:17:26 localhost.localdomain rc.local[2481]: Starting Nexus OSS...
31 Mar 08 00:17:26 localhost.localdomain rc.local[2481]: Removed stale pid file: /home/Jorcen/Environments/nexus/nexus-2.7.0-04/nexus.pid
32 Mar 08 00:17:26 localhost.localdomain systemd[1]: Started /etc/rc.d/rc.local Compatibility.

 
 
chmod +x/etc/rc.d/rc.local
ln -s/etc/rc.d/rc.local/etc/rc.local
2.rc-localを表示します.service
systemctl status rc-local.service
サービスが起動していない場合はrc-localを起動してください.service
3.rc-localを起動する.service
systemctl start rc-local.service
次に、2番目のコマンドでサービスステータスを表示します.ここには起動できないサービスがある可能性があります.なぜですか.
解決:
ファイル/lib/systemd/system/rc-localを編集します.サービス、ConditionFilel**ecutable=/etc/rc.d/rc.local前賞番号注記および#ConditionFilel**ecutable=/etc/rc.d/rc.local
rc-localを再起動します.サービスはシステムctl status rc-localを併用する.サービスステータスが起動したかどうか見てみましょう
4.機器の再起動
/rootの下に複数のファイルtestがあるかどうかを確認します.起動スクリプトが実行されていることを示します.