如何把rc.local里执行的shell脚本的日志内容放到其他位置

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/
原文地址:https://www.cnblogs.com/shengulong/p/9978895.html