1818IP-服务器技术教程,云服务器评测推荐,服务器系统排错处理,环境搭建,攻击防护等

当前位置:首页 - Linux系统 - centos - 正文

君子好学,自强不息!

centos 7 设置开机启动脚本

2023-02-24 | centos | admin | 6336°c
A+ A-
vi /etc/rc.d/rc.local   
在末尾追加 sh脚本

sh脚本要提前赋予执行权限

下面是测试,开机同步北京时间
[root@commonTest bin]# vi /usr/local/bin/data.sh 
#!bin/bash

ntpdate ntp1.aliyun.com
[root@commonTest bin]# chmod 755 data.sh

[root@commonTest bin]# vim /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

/usr/local/bin/date.sh

 



本文来源:1818IP

本文地址:https://www.1818ip.com/post/32557.html

免责声明:本文由用户上传,如有侵权请联系删除!

发表评论

必填

选填

选填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。