linux添加开机启动脚本

[[email protected] ~]# ll /etc/rc.local
lrwxrwxrwx. 1 root root 13 Mar 12 22:20 /etc/rc.local -> rc.d/rc.local
#rc.local中的命令,会在boot时执行
#rc.local文件默认没有执行权限,这样不会boot运行,需要添加x权限。

  

[[email protected] ~]# cat /etc/rc.local
#!/bin/bash

touch /var/lock/subsys/local
/bin/sh /etc/init.d/zabbix_agent.sh
/bin/sh /etc/init.d/mysqld.sh
#把需要执行的命令写入文件

  

[[email protected] ~]# ll /etc/init.d/ | grep sh
-rwxr-xr-x  1 root root    69 Aug  6 19:58 mysqld.sh
-rwxr-xr-x  1 root root    77 Aug  6 20:02 zabbix_agent.sh
#相关的脚本,记得都加上x权限

  

 

  

原文地址:https://www.cnblogs.com/jabbok/p/8497254.html

时间: 2024-08-05 23:59:10

linux添加开机启动脚本的相关文章

linux添加开机自启动脚本示例详解

来源: linux添加开机自启动脚本示例详解 linux下(以RedHat为范本)添加开机自启动脚本有两种方法,先来简单的; 一.在/etc/rc.local中添加如果不想将脚本粘来粘去,或创建链接什么的,则:step1. 先修改好脚本,使其所有模块都能在任意目录启动时正常执行;step2. 再在/etc/rc.local的末尾添加一行以绝对路径启动脚本的行;如:$ vim /etc/rc.local#!/bin/sh## This script will be executed *after*

Linux 添加开机启动项的三种方法

linux 添加开机启动项的三种方法. (1)编辑文件 /etc/rc.local 输入命令:vim /etc/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 sty

linux添加开机自启动脚本

一.在/etc/rc.local中添加 如果不想将脚本粘来粘去,或创建链接什么的, 则: step1. 先修改好脚本,使其所有模块都能在任意目录启动时正常执行; step2. 再在/etc/rc.local的末尾添加一行以绝对路径启动脚本的行; 如: $ vim /etc/rc.local #!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own in

Linux 添加开机启动项的两种方法

1.编辑文件 /etc/rc.local vim /etc/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/subsy

ArchLinux 添加开机启动脚本, 亲测

以下命令以root用户执行 1.创建一个启动service脚本 vim /usr/lib/systemd/system/rc-local.service [Unit] Description="/etc/rc.local Compatibility" [Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 StandardInput=tty RemainAfterExit=yes SysVStartPriori

imx6q android 添加开机启动脚本

1.在xx/out/target/product/sabresd_6dq/root/init.rc中添加以下内容 ========================================== service android-user /system/etc/android-user.sh class main user root group root oneshot ======================================== 2.重新编译boot.img //把in

centos7之添加开机启动服务/脚本

一.添加开机启动脚本 #!/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 parall

Linux启动原理介绍及设置开机启动脚本方法

转自本人个人博客:http://www.xgezhang.com/linux_init_shell.html 之前总是对Linux的整个启动脉络不了解,把这个问题看得很神秘,昨天稍微研究了一下,其实还是很简单的. Linux启动时,所有的启动脚本都放在/etc/init.d/ 下面,而这些脚本又有映射到各个/etc/rcX.d,这个X代表0-6,分别对应不同的系统级别: 0代表关机(halt) 1级别是单用户模式(single) 2级别是多用户级别,这个是默认级 3,4,5未定义,可以提供给用户

centOS7添加开机启动服务/执行脚本

centOS7添加开机启动服务/执行脚本 /etc/rc.d/rc.local  后追加shell脚本 1 开机启动服务 在centos7中添加开机自启服务非常方便,只需要两条命令(以Jenkins为例): #设置jenkins服务为自启动服务 systemctl enable jenkins.service #启动jenkins服务 systemctl start jenkins.service 2 开机执行脚本 在centos7中增加脚本有两种常用的方法: 修改/etc/rc.d/rc/lo