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,说明我们的开机脚本已经运行了!
 
 

最新文章

  1. lucky 的 时光助理
  2. Multiple Contexts have a path of 错误
  3. Linux socket多进程服务器框架一
  4. Curl http_code 状态码 意义及信息
  5. 抓取网页内容生成kindle电子书
  6. c# List<int> 转 string 以及 string [] 转 List<int>
  7. c语言指针说解
  8. sql server 2005+ 行转列
  9. find the safest road--hdu1596
  10. linkin大话设计模式--观察者模式
  11. 模型和字段 -- Django从入门到精通系列教程
  12. ASP.NET Web API编程——模型验证与绑定
  13. Github 快速建库上传本地代码
  14. linux CentOS 安装 nginx+tomcat+java+mysql运行环境
  15. chmod 755 是李鬼(转)
  16. python csv文件转换成xml, 构建新xml文件
  17. Xcode - 添加自定义代码提示
  18. 用Notepad++在文本文件里快速在每行头尾都加上指定的内容(转载)
  19. 管道和FIFO 二
  20. RocketMQ学习笔记(一)eclipse版的quickstart

热门文章

  1. Document.getElementById 与 $('#id')的区别
  2. ios固定高度禁止惯性滚动
  3. 洛谷 P3399 丝绸之路
  4. Linux 内核同步机制
  5. ARP协议详解
  6. PHP运行方式对比
  7. windows程序消息机制(Winform界面更新有关)
  8. win7局域网无法ping通本机的问题解决方法
  9. 【linux】学习笔记
  10. 我的第一个MVC4程序