最近正在折腾写一个开机自动安装软件的shell脚本,用于批量给系统安装软件,
特此记录一个shell脚本开机自动执行的的方法:
大家可能都知道,在其他Linux发行版本如CentOs等在etc目录下会有一个rc.local文件,这个文件是启动加载文件,也就是说,在我们开机后,系统会检查一遍这个文件,并且会自动执行里面写入的命令;
那么,我们只需要把我们想开机自动执行的脚本的执行路径写在这里就可以实现开机自动执行。
以下是rc.local的截图,里面的内容大概如下:

我们只需要把文件写入最下边就可以了。
注意:
rc.local文件需要加上执行权限,chmod +x rc.local
但是,你可能发现你的deepin系统中没有这个rc.local文件,没有关系,自己写一个就可以啦,是可以正常执行的。可以直接复制以下内容:
vim /etc/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.
exit 0
需要执行的放在 exit 0 上边就可以啦!
重启试验一下吧!
2021/05/10更新:
这种方法其实不是一种好的选择,现在推荐的方法是crontab和systemd。

万万没想到




![记录一次WordPress插件Redis Object Cache报错“Redis 无法访问: Connection refused [tcp://127.0.0.1:6379]”故障处理方法-万万没想到](https://oss.wanpeng.life/wp-content/uploads/2024/07/a0f1e0603bc52f8-220x150.png)









评论前必须登录!
立即登录 注册