随笔 - 22  文章 - 0  评论 - 0  阅读 - 93206

sh脚本开机自启动

CentOS系统和Redhat系统如下:
1.修改/etc/rc.d/rc.local为

#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
/root/Desktop/start.sh

“sourece /root/Desktop/start.sh”为要添加开机自启动的脚本,并且要给“/root/Desktop/start.sh”赋予执行权限(chmod +x /root/Desktop/start.sh)
2.chmod 777 rc.local
3.重启系统后就会开始执行预设置执行的脚本。(此种自启动方式不会在GUI界面显示执行的具体进程)**

posted on   韩山隐士  阅读(521)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 使用C#创建一个MCP客户端
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示