当前位置: 首页 > news >正文

wordpress会员卡密丽水百度seo

wordpress会员卡密,丽水百度seo,WordPress 游戏,政府网站建设需要多少钱Linux 服务脚本 一、Linux 开机自动启动服务 ​ linux开机服务原理: ​ ①linux系统启动首先加载kernel ​ ②初始操作系统 ​ ③login验证程序等待用户登陆 ​ 初始化操作系统 ​ kernel加载/sbin/init创建用户空间的第一个程序 ​ 该程序完成操作系统的初…

Linux 服务脚本

一、Linux 开机自动启动服务

​ linux开机服务原理:

​ ①linux系统启动首先加载kernel

​ ②初始操作系统

​ ③login验证程序等待用户登陆

​ 初始化操作系统

​ kernel加载/sbin/init创建用户空间的第一个程序

​ 该程序完成操作系统的初始化:

​ /etc/inittab文件是/sbin/init程序读取的配置文件

# inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#
# To view current default target, run:
# systemctl get-default
#
# To set a default target, run:
# systemctl set-default TARGET.target
#

​ 0-6,6个级别,每种级别之间的差异其实就是启动脚本的种类数量不同而已

级别含义
0halt(Do NOT set initdefault to this)
1Single user mode
2Multiuser,without NFS (The same as 3, if you do not have networking)
3Full multiuser mode
4unused
5X11
6reboot(Do NOT set initdefault to this)

​ 每个级别对应在/etc/rc.d下都有自己的目录

[root@localhost ~]# ls -l /etc/rc.d
total 4
drwxr-xr-x. 2 root root  70 May 15 23:05 init.d
drwxr-xr-x. 2 root root  45 Nov 16  2020 rc0.d
drwxr-xr-x. 2 root root  45 Nov 16  2020 rc1.d
drwxr-xr-x. 2 root root  45 Nov 16  2020 rc2.d
drwxr-xr-x. 2 root root  45 Nov 16  2020 rc3.d
drwxr-xr-x. 2 root root  45 Nov 16  2020 rc4.d
drwxr-xr-x. 2 root root  45 Nov 16  2020 rc5.d
drwxr-xr-x. 2 root root  45 Nov 16  2020 rc6.d
-rw-r--r--. 1 root root 473 Dec  7  2023 rc.local

​ /etc/rc.d目录:

​ init.d目录是所有的原始服务脚本

​ rc*.d目录中是对init.d目录中脚本的软连接

[root@localhost ~]# ls -l /etc/rc.d/rc3.d
total 0
lrwxrwxrwx. 1 root root 20 Apr 17 04:27 K50netconsole -> ../init.d/netconsole
lrwxrwxrwx. 1 root root 17 Apr 17 04:27 S10network -> ../init.d/network

二、Linux 服务管理操作

​ 不同级别中服务脚本的管理命令

​ chkconfig

​ chkconfig-updates and queries runlevelinformation for system services

​ 服务进程的管理命令

​ service

​ service -run a System V init scrip

chkconfig [--list] [--type type][name]

​ 显示系统服务,以及各个级别开关状态

[root@localhost ~]# chkconfig --listNote: This output shows SysV services only and does not include nativesystemd services. SysV configuration data might be overridden by nativesystemd configuration.If you want to list systemd services use 'systemctl list-unit-files'.To see services enabled on particular target use'systemctl list-dependencies [target]'.netconsole     	0:off	1:off	2:off	3:off	4:off	5:off	6:off
network        	0:off	1:off	2:on	3:on	4:on	5:on	6:off

chkconfig --del name

​ 去除系统启动管理服务中的服务

# 删除服务
[root@localhost ~]# chkconfig --del network# 已经被删除
[root@localhost ~]# chkconfig --list networkNote: This output shows SysV services only and does not include nativesystemd services. SysV configuration data might be overridden by nativesystemd configuration.If you want to list systemd services use 'systemctl list-unit-files'.To see services enabled on particular target use'systemctl list-dependencies [target]'.service network supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add network')

chkconfig --add name

​ 添加系统服务,且服务脚本要在/etc/rc.d/init.d目录下

# 添加服务
[root@localhost ~]# chkconfig --add network# 查看是否添加
[root@localhost ~]# chkconfig --list networkNote: This output shows SysV services only and does not include nativesystemd services. SysV configuration data might be overridden by nativesystemd configuration.If you want to list systemd services use 'systemctl list-unit-files'.To see services enabled on particular target use'systemctl list-dependencies [target]'.network        	0:off	1:off	2:on	3:on	4:on	5:on	6:off

chkconfig [--level levels] [--type type] name <on|off|reset|resetpriorities>

​ 调整系统启动管理服务中的服务级别

# 将network在启动级别为1设置不启动
[root@localhost ~]# chkconfig --level 1 network on# 查看是否关闭
[root@localhost ~]# chkconfig --listNote: This output shows SysV services only and does not include nativesystemd services. SysV configuration data might be overridden by nativesystemd configuration.If you want to list systemd services use 'systemctl list-unit-files'.To see services enabled on particular target use'systemctl list-dependencies [target]'.netconsole     	0:off	1:off	2:off	3:off	4:off	5:off	6:off
network        	0:off	1:on	2:on	3:on	4:on	5:on	6:off

​ service SCRIPT COMMAND

​ SCRIPT:系统服务脚本名称,在/etc/rc.d/init.d或软连接的目录/etc/init.d目录中

​ COMMAND:脚本不同,但是基本包含{start|stop|status|restart|reload}

​ service --status-all

​ service network restart

# 查看network服务状态
[root@localhost ~]# service network status
Configured devices:
lo ens33
Currently active devices:
lo ens33

​ Linux系统服务脚本:

​ vi /etc/init.d/network

​ 脚本中必须包含以下两行

# chkconfig: 2345 10 90

​ 被注释的,表示调用chkconfig操作add时默认的各级别开启

​ 10:表示启动级别:先启动后关闭,最大值99

​ 90:表示停止级别:先启动后关闭,最大值99

# description: Activates/Deactivates all network interfaces configured to \

# start at boot time.

#! /bin/bash
#
# network       Bring up/down networking
#
# chkconfig: 2345 10 90
# description: Activates/Deactivates all network interfaces configured to \
#              start at boot time.
#
### BEGIN INIT INFO
# Provides: $network
# Should-Start: iptables ip6tables NetworkManager-wait-online NetworkManager $network-pre
# Short-Description: Bring up/down networking
# Description: Bring up/down networking
### END INIT INFO# Source function library.
. /etc/init.d/functions
……

​ 可以看到相应级别目录中的脚本名称前面包含K或S和一个数值

​ K:关闭服务,后面的数值是关闭优先级

​ S:启动服务,后面的数值是启动优先级

[root@localhost ~]# ls -l /etc/rc.d/rc3.d/
total 0
lrwxrwxrwx. 1 root root 20 Apr 17 04:27 K50netconsole -> ../init.d/netconsole
lrwxrwxrwx. 1 root root 17 Oct 16 08:26 S10network -> ../init.d/network

三、tomcat服务脚本

​ 安装java

# 下载java1.8
[root@localhost ~]# yum -y install java-1.8.0*# 验证是否安装成功
[root@localhost ~]# java -version
openjdk version "1.8.0_412"
OpenJDK Runtime Environment (build 1.8.0_412-b08)
OpenJDK 64-Bit Server VM (build 25.412-b08, mixed mode)

​ bash以交互方式启动时会加载/etc/profile文件,所以在这里定义的环境变量能被用户交互时用到,用户交互启动程序所依赖•

​ 但是系统服务脚本优先在用户登陆前启动,且不会读取/etc/profile

# 下载tomcat9.0
[root@localhost ~]# wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.96/bin/apache-tomcat-9.0.96.tar.gz# 解压文件
[root@localhost ~]# tar -xzvf apache-tomcat-9.0.96.tar.gz # 进入tomcat/bin
[root@localhost ~]# cd apache-tomcat-9.0.96/bin# 启动服务
[root@localhost bin]# ./startup.sh
Using CATALINA_BASE:   /root/apache-tomcat-9.0.96
Using CATALINA_HOME:   /root/apache-tomcat-9.0.96
Using CATALINA_TMPDIR: /root/apache-tomcat-9.0.96/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /root/apache-tomcat-9.0.96/bin/bootstrap.jar:/root/apache-tomcat-9.0.96/bin/tomcat-juli.jar
Using CATALINA_OPTS:   
Tomcat started.# 查看运行进程
[root@localhost bin]# ps -ef | grep java
root       1648      1 25 11:07 pts/0    00:00:03 /usr/bin/java -Djava.util.logging.config.file=/root/apache-tomcat-9.0.96/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /root/apache-tomcat-9.0.96/bin/bootstrap.jar:/root/apache-tomcat-9.0.96/bin/tomcat-juli.jar -Dcatalina.base=/root/apache-tomcat-9.0.96 -Dcatalina.home=/root/apache-tomcat-9.0.96 -Djava.io.tmpdir=/root/apache-tomcat-9.0.96/temp org.apache.catalina.startup.Bootstrap start
root       1676   1371  0 11:08 pts/0    00:00:00 grep --color=auto java# 关闭防火墙
[root@localhost bin]# systemctl stop firewalld
[root@localhost bin]# setenforce 0# 浏览器访问http://your_ip:8080# 停止服务
[root@localhost bin]# ./shutdown.sh

​ 但是这种运行方式需要用户干预,我们更希望的是服务器启动后能将tomcat作为系统服务启动

​ 我们自己实现一个tomcat的系统服务脚本

​ 对于service调取脚本可以传递给脚本的参数应该包含:

​ start

​ stop

​ restart

​ status

​ 作为服务脚本必须实现的内容:

# chkconfig: 123456 2079

# description: This is a Tomcat Server shell scripts

​ 另外,系统还有一个通用的工具脚本,其中包含了一些方便我们服务脚本开发的函数

. /etc/rc.d/init.d/functions

# 创建tomcat
[root@localhost bin]# touch /etc/init.d/tomcat# 添加执行权
[root@localhost bin]# chmod +x /etc/init.d/tomcat[root@localhost bin]# vi /etc/init.d/tomcat
#!/bin/bash
#
# chkconfig: 123456 2079
# description: This is a Tomcat Server shell scripts
. /etc/rc.d/init.d/functions

etc/rc.d/init.d/functions脚本介绍:

​ functions这个脚本是给/etc/init.d里边的文件使用的,提供了一些基础的功能

​ 重要函数:

​ checkpid:检查是否已存在pid,如果有一个存在,返回0(通过查看/proc目录)

​ daemon:启动某个服务。/etc/init.d目录部分脚本的start使用到这个

​ killproc:杀死某个进程。/etc/init.d目录部分脚本的stop使用到这个

​ status:返回一个服务的状态

​ 我们可以在自己的脚本中通过source或.的方式导入

​ tomcat有自己的服务管理脚本

​ 在系统服务脚本中判断服务进程状态

​ 最直接的方式是用进程的PID

​ 观察:bin/startup.sh

​ 发现最终调用catalina.sh脚本

​ 并传参start

​ 所以查找catalina.sh

​ 查找到这行:

elif [ "$1" = "start" ] ; then

​ 向下寻找到分支结束前,添加:

echo "CATALINA_PID:$!

# 打印pid
[root@localhost bin]# vi startup.sh
# 第519行,添加
echo "CATALINA_PID:$!"# 返回编写tomcat
[root@localhost bin]# vi /etc/init.d/tomcat
#!/bin/bash
#
# chkconfig: 123456 2079
# description: This is a Tomcat Server shell scripts
. /etc/rc.d/init.d/functions
tom_home=/root/apache-tomcat-9.0.96/bin
# tomcat启动后将进程ID存在这个文件中
tom_lock_file=/var/lock/subsys/tom.lock
tom_status(){if [ -f $tom_lock_file ]; thenlock_pid=`cat $tom_lock_file`if [ ! -z $lock_pid ];then# 调用函数来检测PID对应的进程是否存在if checkpid `cat $tom_lock_file`; thenecho "tomcat is running( $lock_pid )..." && return 0elseecho "tomcat ( $lock_pid )is not running but lock_fileexist" && return 1fififiecho "tomcat is not running ......"  && return 2
}
tom_start(){if ! tom_status >& /dev/null ; then# 这里启动tomcat,并获取pid存到锁文件中$tom_home/startup.sh |& grep "CATALINA_PID:" | sed 's/CATALINA_PID:\(.*\)/\1/' > $tom_lock_fileecho "tomcat started ..."fitom_status
}
tom_stop(){tom_status$tom_home/shutdown.sh >& /dev/nullecho "tomcat stoped..."echo '' > $tom_lock_file
}
tom_restart()
{tom_stopsleep 1tom_start
}
case $1 instatus)tom_status;;start)tom_start;;stop)tom_stop;;restart)tom_restart;;*)echo $"Usage: $0 {start|stop|status|restart}";;
esac

​ 设置开机自启动

[root@localhost bin]# chkconfig --level 3 tomcat on

文章转载自:
http://dinncotourism.ssfq.cn
http://dinncoperpendicularity.ssfq.cn
http://dinncoern.ssfq.cn
http://dinncohyperirritable.ssfq.cn
http://dinncophysiotherapy.ssfq.cn
http://dinncohandover.ssfq.cn
http://dinncophoneticise.ssfq.cn
http://dinncopeace.ssfq.cn
http://dinncoshmaltz.ssfq.cn
http://dinncoarhythmical.ssfq.cn
http://dinncoredye.ssfq.cn
http://dinncocheeky.ssfq.cn
http://dinncomelodica.ssfq.cn
http://dinncooverprint.ssfq.cn
http://dinncofilmlet.ssfq.cn
http://dinncorelatival.ssfq.cn
http://dinncobahadur.ssfq.cn
http://dinncostalwart.ssfq.cn
http://dinncoretread.ssfq.cn
http://dinncosulfonium.ssfq.cn
http://dinncoadar.ssfq.cn
http://dinncosubtract.ssfq.cn
http://dinncorecrimination.ssfq.cn
http://dinncoaddress.ssfq.cn
http://dinncoleukemogenesis.ssfq.cn
http://dinncoevidently.ssfq.cn
http://dinncolynchet.ssfq.cn
http://dinncoisometrical.ssfq.cn
http://dinncoscoriaceous.ssfq.cn
http://dinncoresin.ssfq.cn
http://dinncoshreveport.ssfq.cn
http://dinncohemogram.ssfq.cn
http://dinncohappening.ssfq.cn
http://dinncoaperture.ssfq.cn
http://dinncospringlet.ssfq.cn
http://dinncobaronship.ssfq.cn
http://dinncobulger.ssfq.cn
http://dinncoundersexed.ssfq.cn
http://dinncobatum.ssfq.cn
http://dinncoethnobotanist.ssfq.cn
http://dinncofabianist.ssfq.cn
http://dinncowinnock.ssfq.cn
http://dinncohomochromous.ssfq.cn
http://dinncode.ssfq.cn
http://dinnconuj.ssfq.cn
http://dinncohexaplarian.ssfq.cn
http://dinncoproximate.ssfq.cn
http://dinncoreenaction.ssfq.cn
http://dinncoumtata.ssfq.cn
http://dinncoduotype.ssfq.cn
http://dinncoproofplane.ssfq.cn
http://dinncopsychologize.ssfq.cn
http://dinncocontraindicate.ssfq.cn
http://dinncobluepencil.ssfq.cn
http://dinncorowdyish.ssfq.cn
http://dinncoter.ssfq.cn
http://dinncofenitrothion.ssfq.cn
http://dinncopetrifactive.ssfq.cn
http://dinncourochordate.ssfq.cn
http://dinncomanizales.ssfq.cn
http://dinncohydrometer.ssfq.cn
http://dinncowhir.ssfq.cn
http://dinncoareopagitic.ssfq.cn
http://dinncopattypan.ssfq.cn
http://dinncoscannable.ssfq.cn
http://dinncokelp.ssfq.cn
http://dinncodecadent.ssfq.cn
http://dinncobisayan.ssfq.cn
http://dinncogreensboro.ssfq.cn
http://dinncotabular.ssfq.cn
http://dinncohousewife.ssfq.cn
http://dinncookka.ssfq.cn
http://dinncoxylylene.ssfq.cn
http://dinncoshirring.ssfq.cn
http://dinncodegage.ssfq.cn
http://dinncocalory.ssfq.cn
http://dinncoglucose.ssfq.cn
http://dinncopicao.ssfq.cn
http://dinncoindigestion.ssfq.cn
http://dinncozigzaggery.ssfq.cn
http://dinncoexcardination.ssfq.cn
http://dinncodescent.ssfq.cn
http://dinncomuddler.ssfq.cn
http://dinncoazimuth.ssfq.cn
http://dinncostuffiness.ssfq.cn
http://dinncoforcedly.ssfq.cn
http://dinncojapanization.ssfq.cn
http://dinncoinstar.ssfq.cn
http://dinncoarchanthropine.ssfq.cn
http://dinncowardenship.ssfq.cn
http://dinncochemiloon.ssfq.cn
http://dinncoacetamide.ssfq.cn
http://dinncoreason.ssfq.cn
http://dinncosialogogue.ssfq.cn
http://dinncomedallic.ssfq.cn
http://dinncoindivisibility.ssfq.cn
http://dinncoungracefully.ssfq.cn
http://dinncochlorhexidine.ssfq.cn
http://dinncowarmish.ssfq.cn
http://dinncowallop.ssfq.cn
http://www.dinnco.com/news/105904.html

相关文章:

  • 赵公口网站建设谷歌浏览器下载安卓版
  • 在线网站搭建系统网站目录扫描
  • wordpress4.9.8漏洞如何优化标题关键词
  • 在线构建网站1688关键词排名查询工具
  • 大馆陶网站手机免费建网站
  • 米趋外贸网站建设曼联vs曼联直播
  • 沙元浦做网站的公司推广软件赚钱
  • 自己做网站卖东西需要交税吗赣州网站建设公司
  • 做企业网站要注意什么比较好的软文发布平台
  • sql数据库添加网站怎样做产品推广
  • 做计算机网站有哪些功能百度投诉中心在线申诉
  • 最好的机票网站建设软文发布推广平台
  • 电商网站设计平台百度推广手机客户端
  • 安康网站建设公司电话免费公司网站建站
  • 公司产品网站应该怎么做举一个网络营销的例子
  • word网站链接怎么做项目推广网站
  • wordpress主题模板视频网站深圳网络推广网络
  • 做网站的例子百度账号快速注册
  • 湛江手机网站建设服务营销案例100例
  • 宁夏网站设计公司北京搜索引擎关键词优化
  • 怎么仿制网站中国seo谁最厉害
  • a站免费最好看的电影片推荐网站免费网站免费
  • 中国建筑网官网查询人员证书查如何推广seo
  • 用别人家网站做跳转信息流广告优化师
  • 简单动画制作企业网站优化软件
  • 婚纱摄影的网站模板任何东西都能搜出来的软件
  • 网站项目策划书模板广州seo顾问
  • 绿色商城网站模板四川最好的网络优化公司
  • 网站后台管理界面html链接式友谊
  • 网页app生成器原理seo搜论坛