OpenModScan:工业自动化工程师必备的免费Modbus调试工具终极指南
2026/4/25 12:47:29
实操步骤(共 3 步)
步骤 1:确保 rc.local 文件可执行(部分系统默认禁用)
bash
运行
sudo chmod +x /etc/rc.local
sudo vim /etc/rc.local
文件首行必须是:#!/bin/sh -e(-e表示脚本执行出错时停止,避免后续命令异常)。
步骤 2:在 rc.local 中添加脚本执行命令
在文件 **exit 0之前 ** 添加你的脚本绝对路径(关键!exit 0之后的内容不会执行):
bash
运行
/usr/local/bin/auto_run.sh &
exit 0
注意:加&表示后台运行,若脚本是前台阻塞型(如持续监控),不加&会导致系统启动卡住。
步骤 3:验证配置
bash
运行
sudo systemctl restart rc-local
/etc/rc.local