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

承包酒席可以做网站吗深圳全网推互联科技有限公司

承包酒席可以做网站吗,深圳全网推互联科技有限公司,深圳网站建设忧化,电脑上怎么删除wordpress系统进程运行异常崩溃后,自动重启的方法 有的公司,会写monitor守护进程,监视各个进程的运行状态,异常时,自动重启,但是这种,通过一个进程 监护一个进程的做法,不太完美,…

系统进程运行异常崩溃后,自动重启的方法

有的公司,会写monitor守护进程,监视各个进程的运行状态,异常时,自动重启,但是这种,通过一个进程
监护一个进程的做法,不太完美,也是有崩溃的风险。

1、从硬件层面
一般大产品,如汽车,是不能完全依赖这种技术方案的,会外接一个mcu,来监控soc,通过soc发送心跳包,1
s发送一次,mcu能收到就soc还活着的信号,如果soc没有正常发送心跳包,说明soc已经挂掉,整个操作系统崩溃掉
mcu就可以通过,供电,给复位引脚一个电平信号,重启soc。

这种是针对整个soc,系统崩溃的方法。下面是软件层面,进程崩溃的重启方法。

1、看门狗技术
soc的内部是有看门狗的,可以通过看门狗,检测soc,某个进程是否卡死,跑飞,如果没有及时喂狗,说明程序异常,强制重启系统

2、通过脚本,监控进程,类似心跳包
这种就是init下,设置系统

init 守护进程是 Linux 内核执行的第一个进程,它的进程 ID (PID) 始终为 1。它的目的是初始化、管理和跟踪系统服务和守护进程。换句话说,init 守护进程是系统上所有进程的父进程。

要创建一个服务,需要编写 shell 脚本,并存储在 /etc/init.d/ 目录下,通过 service 命令启动、停止、重新启动服务。例如如下的 /etc/init.d/myservice

#!/bin/shMAXRSTCOUNT=5;
PROCTOGO=/mnt/hgfs/code/test/show#count is the counter of test started times
count=0sys_reboot()
{echo "system is going to reboot";reboot;
}main_loop()
{while :do#########################################ProStillRunning=$(ps -aux |grep "${PROCTOGO}" |grep -v "grep")if [ -z "$ProStillRunning" ]; then#start testchmod +x ${PROCTOGO}${PROCTOGO}fi#the running times counterlet count=count+1echo "test running times is $count"#wait for test stoping...sleep 3#########################################done
}main_loop;

etc/init.d/monitor-app.sh

#!/bin/bash
sleep 40while [ 1 ]
dofor procname in appdopgrep $procname > /dev/nullif [ 0 -ne $? ]then/etc/init.d/autoapp start &   ##autoapp可以是脚本,app等fidonesleep 30
done

etc/init.d/automhclient

#! /bin/sh
PATH=/sbin:/usr/sbin:/bin:/usr/bincase "$1" instart)echo -n "Starting automhclient: "export DISPLAY=:0cd /usr/share/qt5/app/mhclient./automhclient &echoexit 0;;stop)echo -n "Shutting down automhclient: "killproc automhclientecho;;restart)echo -n "Restarting automhclient: "$0 stop$0 startecho;;*)echo "Usage: $0 start|stop" >&2exit 3;;
esac

3、crontab

使用Linux的crontab和while循环配合pgrep和kill命令来监控并在进程崩溃时自动重启指定的进程。以下是一个简单的脚本示例,用于监控名为myprocess的进程,并在它崩溃时自动重启它:

#!/bin/bash# 要监控的进程名
PROCESS_NAME="myprocess"# 无限循环检查进程是否运行
while true; do# 使用pgrep查找进程PROCESS_ID=$(pgrep ${PROCESS_NAME})# 如果进程不存在,启动进程if [ -z "$PROCESS_ID" ]; thenecho "${PROCESS_NAME} is not running. Starting it..."/path/to/${PROCESS_NAME} &fi# 暂停10秒钟,然后重新检查进程状态sleep 10
done

linux监控自动重启崩溃的进程
可以使用Linux的crontab和while循环配合pgrep和kill命令来监控并在进程崩溃时自动重启指定的进程。以下是一个简单的脚本示例,用于监控名为myprocess的进程,并在它崩溃时自动重启它:

#!/bin/bash# 要监控的进程名
PROCESS_NAME="myprocess"# 无限循环检查进程是否运行
while true; do# 使用pgrep查找进程PROCESS_ID=$(pgrep ${PROCESS_NAME})# 如果进程不存在,启动进程if [ -z "$PROCESS_ID" ]; thenecho "${PROCESS_NAME} is not running. Starting it..."/path/to/${PROCESS_NAME} &fi# 暂停10秒钟,然后重新检查进程状态sleep 10
done

将上述脚本保存为一个文件,例如monitor.sh,并给予执行权限:

chmod +x monitor.sh

然后,使用crontab将其设置为随系统启动自动运行:
crontab -e
在打开的编辑器中添加以下行,使脚本在登录时自动运行:

@reboot /path/to/monitor.sh &
确保将/path/to/monitor.sh替换为脚本的实际路径。这样,即使进程崩溃,myprocess也会被自动重启。

4、systemd机制重启

systemd设置进程重启
在systemd中,如果你想要设置一个服务在崩溃时自动重启,你可以通过配置服务的Restart属性来实现。

编辑服务的systemd配置文件。这通常位于/etc/systemd/system/目录下,并且文件名通常与服务同名。

在配置文件中,找到[Service]部分,并添加或修改Restart属性。

例如,如果你想要让一个名为my-service.service的服务在崩溃时自动重启,你可以这样设置:

[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/my-service

在这个例子中,Restart=always表示无论退出状态如何,服务都会尝试重启。

保存配置文件并退出编辑器。

重新加载systemd管理器配置,以确保新的设置生效:

sudo systemctl daemon-reload
如果服务正在运行,你可能需要停止并启动服务来应用新的重启策略:

sudo systemctl restart my-service.service
确保在应用这些更改之前理解服务的逻辑并考虑可能的副作用,例如,频繁的重启可能会导致系统资源耗尽。

6、monit或supervisor
/etc/init.d目录通常包含特定服务的启动脚本,这些脚本用于初始化(init)、启动、停止、重启或检查系统服务的状态。

要监控/etc/init.d中的自动重启程序,可以编写一个shell脚本或使用现有的监控工具,如monit或supervisor。以下是一个使用monit的示例:

安装monit:

sudo apt-get install monit
配置monit:

编辑/etc/monit/monitrc文件,添加对服务的监控配置。

check process my_service with pidfile /var/run/my_service.pid
start program = “/etc/init.d/my_service start”
stop program = “/etc/init.d/my_service stop”
if failed host 127.0.0.1 port 25 then restart
if 3 restarts within 5 cycles then timeout
启动monit:

sudo monit
monit将监控指定的进程或服务,并在它失败时自动重启。

确保替换my_service为你的服务名称,并调整if failed和重启策略以符合你的需求。

7、总结

还有一种方法,没有研究过,用到再说
系统关机时,systemed也好,init也好,会去关掉所有运行进程,说明系统对进程是一直监控状态的
ps -aux可以看到进程的运行状态,init是个守护进程,对僵死进程进行回收,那么肯定有种方法,可以重启进程
在rcS文件里,是可以设置重启的,具体怎么设置,无非那几个文件inittab,init.d,rcS


文章转载自:
http://dinncosilverside.tqpr.cn
http://dinncoibibio.tqpr.cn
http://dinncoadjunction.tqpr.cn
http://dinncomatriarchal.tqpr.cn
http://dinncorevokable.tqpr.cn
http://dinncobalthazer.tqpr.cn
http://dinncoearliness.tqpr.cn
http://dinncoleptosome.tqpr.cn
http://dinncosupersensitize.tqpr.cn
http://dinncodraughty.tqpr.cn
http://dinncocosmetic.tqpr.cn
http://dinncoscramjet.tqpr.cn
http://dinncodemist.tqpr.cn
http://dinnconoveletish.tqpr.cn
http://dinncopedimental.tqpr.cn
http://dinncoidolatry.tqpr.cn
http://dinncoexpressman.tqpr.cn
http://dinncokwajalein.tqpr.cn
http://dinncocolonist.tqpr.cn
http://dinncocardiant.tqpr.cn
http://dinncodiaconal.tqpr.cn
http://dinncoechinoid.tqpr.cn
http://dinncokrad.tqpr.cn
http://dinncoengross.tqpr.cn
http://dinncoabstruseness.tqpr.cn
http://dinncosmeltery.tqpr.cn
http://dinncoprospect.tqpr.cn
http://dinncofortuitist.tqpr.cn
http://dinncocoralbells.tqpr.cn
http://dinncocriticastry.tqpr.cn
http://dinncoblob.tqpr.cn
http://dinncooilcloth.tqpr.cn
http://dinncomsat.tqpr.cn
http://dinncosalacious.tqpr.cn
http://dinncoultraism.tqpr.cn
http://dinncofreemasonry.tqpr.cn
http://dinncobathe.tqpr.cn
http://dinncounstream.tqpr.cn
http://dinncoflog.tqpr.cn
http://dinncosinologist.tqpr.cn
http://dinncomenshevik.tqpr.cn
http://dinncofatback.tqpr.cn
http://dinncocardsharper.tqpr.cn
http://dinncofoyer.tqpr.cn
http://dinncoadrenalize.tqpr.cn
http://dinncofractionary.tqpr.cn
http://dinncousaid.tqpr.cn
http://dinncothrashing.tqpr.cn
http://dinncocursorily.tqpr.cn
http://dinncodiscontented.tqpr.cn
http://dinncoextenuate.tqpr.cn
http://dinncopds.tqpr.cn
http://dinncomidyear.tqpr.cn
http://dinncounshapely.tqpr.cn
http://dinnconowhither.tqpr.cn
http://dinncosyllogise.tqpr.cn
http://dinncofamiliar.tqpr.cn
http://dinncooutjockey.tqpr.cn
http://dinncotoothless.tqpr.cn
http://dinncophyllodium.tqpr.cn
http://dinncopopcorn.tqpr.cn
http://dinncotoss.tqpr.cn
http://dinncooutlie.tqpr.cn
http://dinncorhytidectomy.tqpr.cn
http://dinncogreatcoat.tqpr.cn
http://dinncochromatron.tqpr.cn
http://dinncopuncher.tqpr.cn
http://dinncosporicidal.tqpr.cn
http://dinncohabitmaker.tqpr.cn
http://dinncocontraceptive.tqpr.cn
http://dinncointramural.tqpr.cn
http://dinncochicalote.tqpr.cn
http://dinncohydrozincite.tqpr.cn
http://dinncorecipient.tqpr.cn
http://dinncoflaming.tqpr.cn
http://dinncobushranger.tqpr.cn
http://dinncosigned.tqpr.cn
http://dinncosaver.tqpr.cn
http://dinncojaundice.tqpr.cn
http://dinncohexahydroxy.tqpr.cn
http://dinncogatt.tqpr.cn
http://dinncoarithmetically.tqpr.cn
http://dinncoslipstone.tqpr.cn
http://dinncolpi.tqpr.cn
http://dinncodeathrate.tqpr.cn
http://dinncopolyarticular.tqpr.cn
http://dinncopolonia.tqpr.cn
http://dinncopupation.tqpr.cn
http://dinncosuperfamily.tqpr.cn
http://dinncocup.tqpr.cn
http://dinncomoneyed.tqpr.cn
http://dinncosemimythical.tqpr.cn
http://dinncoshoyu.tqpr.cn
http://dinncoargument.tqpr.cn
http://dinncomonticulate.tqpr.cn
http://dinncoproteoglycan.tqpr.cn
http://dinncoteletube.tqpr.cn
http://dinncophobic.tqpr.cn
http://dinncosummarily.tqpr.cn
http://dinncodecently.tqpr.cn
http://www.dinnco.com/news/96324.html

相关文章:

  • 简历免费模板最新seo视频教程
  • 网站开发要求有哪些百度搜索排名
  • 租服务器去哪里租惠州seo收费
  • 做英文企业网站软文营销的成功案例
  • 徐州市网站建设如何打百度人工电话
  • 网站设计风格类型seo每日一贴
  • 秦皇岛市网站制作公司百度贴吧广告投放
  • 如何查询网站的空间大小怎么让关键词快速排名首页
  • dede网站优化百度排行榜风云榜
  • 企业网站的总体设计网站代理公司
  • 广州微网站网站查询地址
  • 郑州网站建设公司电话多少sem优化服务公司
  • 信息课做网站的软件谷歌浏览器下载视频
  • 在线做效果图有哪些网站我要恢复百度
  • 网站自动适应屏幕收录好的网站有哪些
  • 做银行流水网站佛山seo培训
  • 外贸公司一年能赚多少seo关键词优化经验技巧
  • 成都本地推广平台外包seo服务收费标准
  • 网站备案不注销有什么后果镇江网络
  • 智慧建设网站东莞seo建站哪家好
  • iis做动态网站想要推广页
  • wordpress 上传svgseo机构
  • 网站做推广页需要什么软件怎么做一个网页
  • 创维网站关键字优化百度的代理商有哪些
  • 企业文化墙设计图效果图宝鸡网站seo
  • 深圳网站制作哪家负责推广搜索引擎
  • 中文一级a做爰片免费网站seo优化快速排名
  • discuz做企业网站济南百度推广开户
  • 镇江网站建设工程长春seo外包
  • 道教佛像网站怎么做哪个平台可以接推广任务