centOS 7 创建systemd服务 vi /usr/lib/systemd/system/stopSrv.service 需要把ExecStart=/home/my_script这一行换成自己的脚本路径 [Unit] Description=close services before reboot and shutdown DefaultDependencies=no Before=shutdown.target reboot.target halt.target # This works because it is installed in the target and will be # executed before the target state is entered # Also consider kexec.target [Service] Type=oneshot ExecStart=/home/my_script #your path and filename [Install] WantedBy=halt.target reboot.target shutdown.target 启动服务systemctl enable stopSrv centOS 6 编写脚本文件vi /etc/init.d/crsshut #!/bin/bash /oracle/app/grid/product/11.2.0/bin/crsctl stop crs 添加可执行权限chmod +x /etc/init.d/crsshut 创建链接ln -s /etc/init.d/crsshut /etc/rc0.d/K01crsshut ln -s /etc/init.d/crsshut /etc/rc6.d/K01crsshut ln -s /etc/init.d/crsshut /var/lock/subsys/crsshut 防止重启丢失vi /etc/rc.local ln -s /etc/init.d/crsshut /var/lock/subsys/crsshut