5.开机自动运行脚本--三种方法
方法一:
修改/etc/rc.d/rc.local文件
方法二:
用crontab -e
@reboot /home/script.sh
方法三:
仅适用于systemd系统,即ps aux,pid为1的进程是systemd的就是

在/etc/systemd/system/下建一个文件
vim script.service [Unit] Description=Run a Custom Script at Startup After=default.target [Service] ExecStart=/home/script.sh [Install] WantedBy=default.target
把脚本/home/script.sh放在/etc/systemd/system/下
更新systemd配置文件
systemctl daemon-reload
systemctl enable script.service

浙公网安备 33010602011771号