当前位置:首页 » 操作系统 » 开机自启动linux

开机自启动linux

发布时间: 2022-08-02 08:58:16

linux:怎么设置服务开机自动启动

linux设置开机服务自动启动/关闭自动启动命令
[root@localhost
~]#
chkconfig
--list
显示开机可以自动启动的服务
[root@localhost
~]#
chkconfig
--add
***
添加开机自动启动***服务
[root@localhost
~]#
chkconfig
--del
***
删除开机自动启动...

② 怎样将一个linux服务设置成开机启动

linux设置开机服务自动启动

[root@localhost ~]# chkconfig --list 显示开机可以自动启动的服务

[root@localhost ~]# chkconfig --add *** 添加开机自动启动***服务

[root@localhost ~]# chkconfig --del *** 删除开机自动启动***服务

www.2cto.com

[root@localhost ~]# setup 可以在shell图形终端里面配置的命令,去service里选择

[root@localhost ~]# ntsysv 在shell终端图形配置开机启动服务命令,选项没上面那个多

setup 、rc.local 和chkconfig三种方式都可以设置

第一种)

输入#setup指令进入系统服务菜单,选择你想启动的服务比如httpd,然后重起机器或者/etc/rc.d./init.d/httpd

start

www.2cto.com

第二种)

把启动命令放到/etc/rc.d/rc.local文件里这样就可以每次启动的时候自动启动服务了,例如对于apache,编译好apache后会在安装目录的bin下生成apachectl文件,这是个启动脚本,我们只需要把这个命令加到rc.local里就可以了

(suse没有rc.local。SUSE是可以这么定义自己的脚本的,如果希望在切换运行级之前和之后运行自己的脚本,那么可以分别创建:

/etc/init.d/before.local

/etc/init.d/after.local)

echo /usr/local/apache/bin/apachectl>> /etc/rc.d/rc.local,

设置服务自动启动的方式是在rc.local里还可以加入类似以下的一些脚本:

#sshd

/usr/local/sbin/sshd

#proftpd

/usr/local/sbin/proftpd

#apache

/home/apache/bin/apachectl start

#mysql

/home/mysql/bin/safe_mysqld --port=3306 &

#start oracle8i listener first

su - oracle -c 'lsnrctl start'

#start oracle8i

su - oracle -c 'dbstart'

第三种)

通过chkconfig指令.

使用chkconfig命令来把某项服务加到系统的各项运行级别中,步骤如下,

1 创建启动脚本.

对于apache,mysql,ssh这样的软件都是自己带的,我们只要稍微修改一下使之支持chkconfig就可以了

2 修改脚本

我们需要在脚本的前面加上一下2行,才能支持chkconfig命令

# chkconfig: 2345 08 92

#

# description: Automates a packet filtering firewall withipchains.

#

chkconfig:后面定义的使启动服务的运行级别(例子中使2345启动改服务),以及关闭和启动服务的顺序,(上例中关闭服务的顺序使8,启动的顺序使92)

descriptions:对改服务的描述(上例中是ipchains包过滤),你可以换成自己想要的

修改好之后执行

cp 你的脚本 /etc/rc.d/init.d/脚本名

chmod 700 /etc/rc.d/init.d/脚本名

chkconfig --add 脚本名

例如:

将其加入Linux启动过程,仅在level 3, level 5级别下运行

[root@Tester init.d]/sbin/chkconfig --add apache-httpd

[root@Tester init.d]/sbin/chkconfig --level 35 apache-httpdon

之后就可以了,以后每次重新启动服务器都会自动启动和关闭我们的服务了
需要解决更多linux问题,详情请看 http://www.linuxprobe.com/chapter-00.html
望采纳!

③ linux怎么让程序开机自动启动

1. 开机启动时自动运行程序
Linux加载后, 它将初始化硬件和设备驱动, 然后运行第一个进程init。init根据配置文件继续引导过程,启动其它进程。通常情况下,修改放置在
/etc/rc或
/etc/rc.d 或
/etc/rc?.d
目录下的脚本文件,可以使init自动启动其它程序。例如:编辑/etc/rc.d/rc.local 文件(该文件通常是系统最后启动的脚本),在文件最末加上一行“xinit”或“startx”,可以在开机启动后直接进入X-Window。
2. 登录时自动运行程序
用户登录时,bash先自动执行系统管理员建立的全局登录script :
/ect/profile
然后bash在用户起始目录下按顺序查找三个特殊文件中的一个:
/.bash_profile、
/.bash_login、
/.profile,
但只执行最先找到的一个。因此,只需根据实际需要在上述文件中加入命令就可以实现用户登录时自动运行某些程序(类似于DOS下的Autoexec.bat)。

④ 如何让linux系统开机自动启动我的程序

试试以后台方式自启动你需要运行的程序,./app.out
&,就是在后面加上个&符号,而且我记得linux里面自启动程序在/etc/init.d/rcs里面吧。

⑤ linux 怎么配置开机自启动

Linux如果是在
虚拟机
里的话,是无法开机自启动的,如果是在另一个硬盘里的话,在bios里调整硬盘启动的优先级就可以了。

⑥ linux 怎么把服务设置开机启动

如果是已经安装好的服务,需要使用chkconfig设置开机启动。以MySQL为例,因各发行版不同,以及安装方式的差异,服务器的启动脚本可能会有细微不同,现假设服务脚本文件是/etc/init.d/mysqld。
首先查看服务是否正确注册
$ service --status-all | grep mysqld | grep -v 'grep'如果有含有mysqld文字的一行返回,则代表已正确注册;若没有需执行如下命令:
$ sudo chkconfig add mysqld
第二步设置开机自启动
$ sudo chkconfig mysqld on
附:查看所有服务及其运行级别的命令
$ chkconfig --list

⑦ Linux配置开机自启动执行脚本有哪些方法

Linux配置开机自启动执行脚本的方法有很多,这里分享两种方法,分别是修改/etc/rc.local方法和chkconfig管理设置的方法,均可实现Linux配置开机自启动执行脚本的功能!
设置test.sh为开机要启动的脚本
[root@oldboy scripts]# vim /server/scripts/test.sh
[root@oldboy scripts]# cat /server/scripts/ test.sh
#!/bin/bash
/bin/echo $(/bin/date +%F_%T) >> /tmp/ test.log
方法一:修改/etc/rc.local
[root@oldboy ~]# ll /etc/rc.local
lrwxrwxrwx. 1 root root 13 Mar 30 10:50 /etc/rc.local -> rc.d/rc.local
修改/etc/rc.local文件
[root@oldboy scripts]# tail -n 1 /etc/rc.local
/bin/bash /server/scripts/test.sh >/dev/null 2>/dev/null
重启系统,查看结果
[root@oldboy ~]# cat /tmp/test.log
2018-03-30_12:00:10
方法二:chkconfig管理
删除掉方法一的配置
[root@oldboy ~]# vim /etc/init.d/test
#!/bin/bash
# chkconfig: 3 88 88
/bin/bash /server/scripts/test.sh >/dev/null 2>/dev/null
[root@oldboy ~]# chmod +x /etc/init.d/test
添加到chkconfig,开机自启动
[root@oldboy ~]# chkconfig --add test
[root@oldboy ~]# chkconfig --list test
test 0:off 1:off 2:off 3:on 4:off 5:off 6:off
重启系统,查看结果
[root@oldboy ~]# cat /tmp/test.log
2018-03-30_12:00:10
2018-03-30_12:33:20
操作成功
关闭开机启动
[root@oldboy ~]# chkconfig test off
[root@oldboy ~]# chkconfig --list test
test 0:off 1:off 2:off 3:off 4:off 5:off 6:off
从chkconfig管理中删除test
[root@oldboy ~]# chkconfig --list test
test 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@oldboy ~]# chkconfig --del test
[root@oldboy ~]# chkconfig --list test
service test supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add test')

⑧ 如何自定义linux服务并设置服务开机启动

1. 服务概述
在linux操作系统下,经常需要创建一些服务,这些服务被做成shell脚本,这些服务需要在系统启动的时候自动启动,关闭的时候自动关闭。
将需要自动启动的脚本/etc/rc.d/init.d目录下,然后用命令chkconfig --add filename将自动注册开机启动和关机关闭。实质就是在rc0.d-rc6.d目录下生成一些文件连接,这些连接连接到/etc/rc.d /init.d目录下指定文件的shell脚本。

2. 手工创建服务
在/etc/rc.d/init.d目录下创建shell脚本,文件名auto_run。
设置脚本的运行权限chmod +x auto_run。
然后在rc0.d-rc6.d目录下分别创建文件连接。
ln -s /etc/rc.d/init.d/auto_run /etc/rc.d/rc2.d/S99auto_run
ln -s /etc/rc.d/init.d/auto_run /etc/rc.d/rc3.d/S99auto_run
ln -s /etc/rc.d/init.d/auto_run /etc/rc.d/rc5.d/S99auto_run
ln -s /etc/rc.d/init.d/auto_run /etc/rc.d/rc0.d/K01auto_run
ln -s /etc/rc.d/init.d/auto_run /etc/rc.d/rc6.d/K01auto_run

这样系统在启动的时候,就会运行auto_run 并加上start参数,等同于执行命令auto_run start。
在系统关闭的时候,就会运行auto_run,并加上stop参数,等同于运行命令auto_run stop。

创建连接的6条命令可以用命令chkconfig --add auto_run来完成,这样就简单多了,还不容易出错。
下面就介绍一下chkconfig命令。
3. chkconfig命令用法
语法:
chkconfig --list [name]
chkconfig --add name
chkconfig --del name
chkconfig [--level levels] name <on|off|reset>
chkconfig [--level levels] name

⑨ linux开机自启动在哪里设置

chkconfig命令设置

⑩ linux系统自启动在哪里设置

他的这一个自启动一般情况都在他的这一个相应的设置里面,你可以直接打开设置,然后把他的这一个相应的启动程序点击一下关闭或启动就行。

热点内容
如何改变vivo手机账户密码 发布:2024-05-19 10:56:07 浏览:376
sql的length函数 发布:2024-05-19 10:55:15 浏览:545
数据库管理系统设计报告 发布:2024-05-19 10:49:50 浏览:684
linux怎么将驱动编译进内核 发布:2024-05-19 10:23:47 浏览:768
c语言读程序题 发布:2024-05-19 10:13:52 浏览:675
新的安卓手机怎么样下载微信 发布:2024-05-19 10:05:06 浏览:879
加9的算法 发布:2024-05-19 10:04:15 浏览:264
新名图配置怎么样 发布:2024-05-19 09:31:30 浏览:95
php获取子节点 发布:2024-05-19 09:21:18 浏览:160
php生成html 发布:2024-05-19 09:20:24 浏览:795