rc.local的日志内容默认是/var/log/boot.log

/etc/rc.d/rc.local文件的文件头是#!/bin/sh ,我们把这修改成#!/bin/sh -x,这样系统启动后就会把/etc/rc.d/rc.local里面的指令或脚本不能执行的日志写入/var/log/messages,或者/var/log/boot.log里,自己验证

 

下面的配置会把rc.local里要执行的sh脚本的日志内容输出到/tmp/rc.local.log里

 

exec 1>/tmp/rc.local.log 2>&1  # send stdout and stderr from rc.local to a log file
set -x                         # tell sh to display commands before execution



https://www.h2mes.com/2017/08/16/%E5%85%B3%E4%BA%8ELinux%E5%90%AF%E5%8A%A8%E6%96%87%E4%BB%B6rc-local%E7%9A%84%E8%A7%A3%E6%83%91/

相关文章:

  • 2021-11-27
  • 2022-12-23
  • 2021-05-18
  • 2022-01-10
  • 2021-09-08
  • 2022-01-15
  • 2021-08-23
  • 2022-12-23
猜你喜欢
  • 2021-08-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-20
  • 2022-12-23
相关资源
相似解决方案