掉电脉冲映射串口log和dmesg到文件中的log

1.echo 1 > /mytest/boot_times

2.systemctl enable i2c_dmesg.service

 

root:/mytest# tree
.
|-- boot_times
|-- i2c_dmesg.txt

root:/etc# cat i2c_dmesg.sh
#!/bin/sh

value=$(cat /mytest/boot_times)

# Keep dmesg file the same as console log
echo "========hello: reboot=$value========" >> /mytest/i2c_dmesg.txt
/bin/dmesg >> /mytest/i2c_dmesg.txt
echo "========hello: reboot=$value========" > /dev/console

let value=value+1
echo $value > /mytest/boot_times

sync

sync

root:/etc# cat /lib/systemd/system/i2c_dmesg.service 
[Unit]
Description=dmesg for i2c oops
After=weston.service

[Service]
ExecStart=/etc/i2c_dmesg.sh
Type=simple

[Install]
WantedBy=multi-user.target

 

posted on 2018-10-01 17:49  Hello-World3  阅读(186)  评论(0编辑  收藏  举报

导航