fedora20发布,不对rc.local支持,其实只是删除了rc.local文件,如果想在开机时能够运行自己写的脚本,只要新建rc.local文件就可以了,下面让我们来测试下吧:
环境:fedora20 GNOME桌面
1./etc/rc.local其实是/etc/rc.d/rc.local的软连接,那么:
vi /etc/rc.d/rc.local
 #!/bin/bash
#this is a script foe nexus start,if the nexus is startting,return.
echo "nexus verify.."
testing8081=`(netstat -an|grep )`
if [ "NULL$testing8081" = "NULL" ] ; then
echo "nuxus starting..."
/home/Jorcen/Environments/nexus/nexus-2.7.-/bin/nexus start
else
echo -n "nexus had started,do you need restart it?(Y/N):"
read verify
if [ "$verify" = "Y" ] ; then
/home/Jorcen/Environments/nexus/nexus-2.7.-/bin/nexus restart
echo "nexus restared.."
fi
fi

编 辑文件/lib/systemd/system /rc-local.service,将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=
RemainAfterExit=yes
SysVStartPriority=

step2

 [root@localhost Jorcen]# chmod +x /etc/rc.d/rc.local
[root@localhost Jorcen]# ln -s /etc/rc.d/rc.local /etc/rc.local
[root@localhost Jorcen]# systemctl status rc-local.service
rc-local.service - /etc/rc.d/rc.local Compatibility
Loaded: loaded (/usr/lib/systemd/system/rc-local.service; static)
Active: failed (Result: exit-code) since Sat -- :: CST; 2min 44s ago
Process: ExecStart=/etc/rc.d/rc.local start (code=exited, status=/EXEC) Mar :: localhost.localdomain systemd[]: Starting /etc/rc.d/rc.local...
Mar :: localhost.localdomain systemd[]: rc-local.service: control p...
Mar :: localhost.localdomain systemd[]: Failed to start /etc/rc.d/r...
Mar :: localhost.localdomain systemd[]: Unit rc-local.service enter...
[root@localhost Jorcen]# systemctl start rc-local.service
[root@localhost Jorcen]# systemctl status rc-local.service
rc-local.service - /etc/rc.d/rc.local Compatibility
Loaded: loaded (/usr/lib/systemd/system/rc-local.service; static)
Active: active (running) since Sat -- :: CST; 27s ago
Process: ExecStart=/etc/rc.d/rc.local start (code=exited, status=/SUCCESS)
Main PID: (wrapper)
CGroup: name=systemd:/system/rc-local.service
├─ /home/Jorcen/Environments/nexus/nexus-2.7.-/bin/jsw/linux-x86-/wrapper /home/Jorcen/Environments/nexus/nexus-2.7.-/bin/js...
└─ java -Djava.net.preferIPv4Stack=true -Dcom.sun.jndi.ldap.connect.pool.protocol=plain ssl -Djava.library.path=bin/jsw/lib -classpa... Mar :: localhost.localdomain systemd[]: Starting /etc/rc.d/rc.local Compatibility...
Mar :: localhost.localdomain rc.local[]: nexus verify..
Mar :: localhost.localdomain rc.local[]: nuxus starting...
Mar :: localhost.localdomain rc.local[]: ****************************************
Mar :: localhost.localdomain rc.local[]: WARNING - NOT RECOMMENDED TO RUN AS ROOT
Mar :: localhost.localdomain rc.local[]: ****************************************
Mar :: localhost.localdomain rc.local[]: Starting Nexus OSS...
Mar :: localhost.localdomain rc.local[]: Removed stale pid file: /home/Jorcen/Environments/nexus/nexus-2.7.-/nexus.pid
Mar :: localhost.localdomain systemd[]: 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.service,将ConditionFilel***ecutable=/etc/rc.d/rc.local前面奖赏#号注释掉 及#ConditionFilel***ecutable=/etc/rc.d/rc.local
再次启动下rc-local.service并用systemctl status rc-local.service看看状态是不是已经启动起来了
4.重启机器
查看/root下是不是多了个文件test,说明我们的开机脚本已经运行了!
 
 

linux_fedora nexus_auto_start的更多相关文章

随机推荐

  1. 快速调试chromium

    上一篇我们简单的将了在Ubuntu上编译chromium,android content_shell_apk的编译,一切顺利的就能生成apk.但是我们仅仅只是照搬了人家google开源的东西,作为一个 ...

  2. php数组编码转换函数的示例

    场景说明/问题描述: Ajax提交页面编码为gb2312,数据库编码为utf8,在不更改页面及数据库编码的情况下插入数据. 自定义函数:  代码如下 复制代码 function array_iconv ...

  3. 微软的COM中GUID和UUID、CLSID、IID

    摘自:http://blog.csdn.net/zhongguoren666/article/details/6711396 当初微软设计com规范的时候,有两种选择来保证用户的设计的com组件可以全 ...

  4. ORACLE 对用户密码做限制

    1. 查看默认设置 2. PASSWORD_LIFE_TIME 60 --口令的生命周期,超过这段时间口令可能会自动过期,是否过期要看是否设定了PASSWORD_GRACE_TIME PASSWORD ...

  5. UI3_UIView自动布局

    // // ViewController.m // UI3_UIView自动布局 // // Created by zhangxueming on 15/7/1. // Copyright (c) 2 ...

  6. 爱莲(iLinkIT)的架构与原理

    随着移动互联网时代的到来,手机正在逐步替代其他的设备,手机是电话.手机是即时通讯,手机是相机,手机是导航仪,手机是钱包,手机是音乐播放器……. 除此之外,手机还是一个大大的U盘,曾几何时,我们用一根长 ...

  7. C89 和 C99的标准比较

    本文转载自: C89和C99标准比较  原文转载自: http://blog.programfan.com/article.asp?id=14051  http://blog.csdn.net/xgb ...

  8. eclipse 最全快捷键(网络收集)

    Ctrl+1 快速修复(最经典的快捷键,就不用多说了) Ctrl+D: 删除当前行 Ctrl+Alt+↓ 复制当前行到下一行(复制增加) Ctrl+Alt+↑ 复制当前行到上一行(复制增加) Alt+ ...

  9. 使用tortoisegit管理git 和 权限验证

    1 安装Git 2 安装Tortoise 3 在git.oschina 或者 github上创建项目 4 Tortoise配置 TortoiseGit 使用扩展名为ppk的密钥,而不是ssh-keyg ...

  10. JavaScript创建对象的写法

    JavaScript 有Date.Array.String等这样的内置对象,功能强大使用简单,人见人爱,但在处理一些复杂的逻辑的时候,内置对象就很无力了,往往需要开发者自定义对象.   对象是什么 从 ...