CentOS开机自动运行自己的脚本详解

时间:2023-03-09 08:08:33
CentOS开机自动运行自己的脚本详解

一、root权限编辑/etc/rc.d/rc.local

su
cd /etc/rc.d/
vi rc.local

二、在这个文件加上你要执行的脚本,全部内容如下:

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff. touch /var/lock/subsys/local
mount //192.168.0.3/data2-1 /mnt/data2-1 -o username=un,password=123
mount //192.168.0.3/data2-2 /mnt/data2-2 -o username=un,password=123
mount //192.168.0.3/data2-3 /mnt/data2-3 -o username=un,password=123
mount //192.168.0.3/data2-4 /mnt/data2-4 -o username=un,password=123
mount //192.168.0.3/data2-5 /mnt/data2-4 -o username=un,password=123