Linux rc.d路径下文件执行时候把日志输出到log
来源:互联网 发布:长沙网络培训 编辑:程序博客网 时间:2024/04/29 14:10
有时我们自己在/etc/rc.d/rc.local里面增加的随机器启动的脚本和指令总是不能自动加载和启动,类似的还有/etc/rc.d/init.d里面的各种系统启动项,
机器启动后手动执行脚本又能成功,经常被搞得晕头转向的。经过测试和查找资料,终于解决了这问题,解决方式如下
/etc/rc.d/rc.local文件的文件头是#!/bin/sh ,我们把这修改成#!/bin/sh -x,这样系统启动后就会把/etc/rc.d/rc.local里面的指令或脚本不能执行的日志写入/var/log/messages
,我们查看messages文件内容就知道具体的问题出在哪里了
--
例如 /etc/rc.d/init.d/tomcat8 的出错日志如下
Oct 8 15:54:49 iZ23psiz6rgZ tomcat8: ++ expr 'lrwxrwxrwx 1 root root 59 Oct 8 15:18 /etc/rc.d/init.d/tomcat8 -> /usr/programfile/tomcat/apache-tomcat-8.0.27/bin/startup.sh' : '.*-> \(.*\)$'
Oct 8 15:54:49 iZ23psiz6rgZ systemd: Started OpenSSH server daemon.
Oct 8 15:54:49 iZ23psiz6rgZ tomcat8: + link=/usr/programfile/tomcat/apache-tomcat-8.0.27/bin/startup.sh
Oct 8 15:54:49 iZ23psiz6rgZ tomcat8: + expr /usr/programfile/tomcat/apache-tomcat-8.0.27/bin/startup.sh : '/.*'
Oct 8 15:54:49 iZ23psiz6rgZ tomcat8: + PRG=/usr/programfile/tomcat/apache-tomcat-8.0.27/bin/startup.sh
Oct 8 15:54:49 iZ23psiz6rgZ tomcat8: + '[' -h /usr/programfile/tomcat/apache-tomcat-8.0.27/bin/startup.sh ']'
Oct 8 15:54:49 iZ23psiz6rgZ tomcat8: ++ dirname /usr/programfile/tomcat/apache-tomcat-8.0.27/bin/startup.sh
Oct 8 15:54:49 iZ23psiz6rgZ tomcat8: + PRGDIR=/usr/programfile/tomcat/apache-tomcat-8.0.27/bin
Oct 8 15:54:49 iZ23psiz6rgZ tomcat8: + EXECUTABLE=catalina.sh
Oct 8 15:54:49 iZ23psiz6rgZ tomcat8: + false
Oct 8 15:54:49 iZ23psiz6rgZ tomcat8: + '[' '!' -x /usr/programfile/tomcat/apache-tomcat-8.0.27/bin/catalina.sh ']'
Oct 8 15:54:49 iZ23psiz6rgZ tomcat8: + exec /usr/programfile/tomcat/apache-tomcat-8.0.27/bin/catalina.sh start start
Oct 8 15:54:49 iZ23psiz6rgZ tomcat8: Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
Oct 8 15:54:49 iZ23psiz6rgZ tomcat8: At least one of these environment variable is needed to run this program
说明在tomcat8里面需要定义JAVA_HOME 环境变量(此时系统还未启动完毕,JAVA_HOME尚未被定义)
- Linux rc.d路径下文件执行时候把日志输出到log
- linux 下文件的路径
- Linux log日志路径
- Windows下文件复制到Linux系统
- windows下文件路径与Linux下文件路径的比较
- 路径下文件遍历
- cocos2dx 把log输出到命令窗口
- Android log日志输出到文件
- log日志输出到文件配置
- Windows与Linux下文件路径的表示
- windows系统和Linux系统下文件路径"\" 和 “/”
- Linux和Windows平台下文件路径的异同
- 关于 Linux 下文件读取/写入/执行 的权限详解
- python输出日志到控制台和文件
- Linux下文件解压缩
- linux下文件锁
- linux下文件结构
- Linux下文件打包
- SD--物料确定的数据表
- 分类与聚类 监督学习与无监督学习
- XML-RPC 的 Apache 实现
- 高通平台msm8909 LK 实现LCD 兼容
- python多线程编程基础
- Linux rc.d路径下文件执行时候把日志输出到log
- 《招聘一个靠谱的 iOS》—参考答案(下)
- 基于用户投票的排名算法Reddit
- 解决冲突
- iOS开源库和完整应用
- 奥卡姆剃刀
- Linux下C语言的本地化/国际化实现
- [生成树][Uva1395][Slim Span]
- ZOJ 3197 Google Book