进程监控 shell Linux 脚本

shell脚本实现服务器进程监控的方法 主要介绍了shell脚本实现服务器进程监控的方法,非常不错,具有参考借鉴价值,需要的朋友参考下吧 立即下载

shell 脚本 实现进程监控

#!/bin/sh
host_dir=/home/www/computer-vision
worker=1
for((i=1;i<= ${worker} ;i++));
do
proc_name="ASES${i}"
file_name="monitor.log"
pid=0
proc_num()          
{
    num=`ps -ef | grep $proc_name | grep -v grep | wc -l`
    return $num
}
proc_id()      
{
    pid=`ps -ef | grep $proc_name | grep -v grep | awk '{print $2}'`
}
proc_num
number=$?
if [ $number -eq 0 ]
then
    `rm -rf ${host_dir}/${proc_name}`
    cp -rf ${host_dir}/ASES ${host_dir}/${proc_name}
    cd $host_dir/${proc_name}/
    mv ASES_p0 ${proc_name}    
    nohup ./${proc_name} & 
    echo 'start'
    proc_id
    echo ${pid},${proc_name} `date` >> $host_dir/$file_name
fi
done
 

 

linux进程监控shell脚本代码 主要为大家分享一个监控linux进程的shell脚本,当程序异常退出时可以自动重启,涉及到捕获进程信号与重启进程的命令与知识 立即下载

相关推荐

STM32-DAC定时器触发三角波生成【频率与幅度精准控制】

本文详细介绍了STM32 DAC定时器触发三角波生成的原理与实现方法,涵盖硬件配置、频率与幅度精准控制技巧及代码实现。通过定时器触发DAC模块,可灵活调节三角波的频率和幅度,适用于信号发生器等高精度应用场景。

weixin_29161785的博客 457

shell监控进程脚本

做一个服务监控重启的脚本。本质就是用一个shell命令去监控服务状态,如果宕机就会自动重启并追加到日志中。.再对crontab命令进行设置 命令:crontab -e。

zhangyuchuan104的博客 1149

嵌入式开发必备:UART、RS232、RS485通信协议实战对比(附代码示例)

本文从嵌入式开发实战角度,深度对比了UART、RS232和RS485三种核心串行通信协议。详细解析了它们的工作原理、硬件连接、代码配置及典型应用场景,并提供了基于通信距离、节点数量和电磁环境的三维度选型指南,帮助开发者根据项目需求做出最优技术决策。

i0j1k2l3m的博客 477

shell脚本监控进程

背景 Linux环境中有个很重要的服务需要持续运行,发现服务停止后能够自动拉起 下面是我在项目中用到的监控click house服务的监控脚本,每隔10秒去检查一次 shell脚本后台启动命令 nohup sh checkprocess.sh & #! /bin/bash #restart scrape news process if the process exited accidentally log_file="restart_sh.log" # return the current da

zh_404的博客 4266

ACM论文LaTeX模板解析(三)| 文章顶部信息(Top matter))Part 1

文章顶部信息(Top matter))Part 1,文章类型、作者信息等

FreshManInC的博客 4857

Vectorless dynamic动态功耗分析——Voltus

power 计算工具会根据设计信息和用户提供的activity和switching约束来生成虚拟的worst-case的power vector,难点在于哪些instances视为switching,在没有仿真的前提下如何确定开关的时间,使用timing文件(TWF)

qq_44347276的博客 2797

Linux下使用Shell脚本实现进程监控

在 Linux 平台下,shell 脚本监控是一个非常简单、方便的工具,它可以有效的对服务器、进程进行监控,对系统开发以及进程维护人员非常有帮助。

zhongcaogen的专栏 5057

【Jlink & C#】通过C#实现Jlink RTT上位机的功能

某天看到安富莱家的自己开发的调试器可以实现输出中文调试信息到自己编写的Jlink RTT上位机上,觉得无比神奇,略好奇到底是如何做的,找了很久,发现其上位机的对应的实现好像也没有完全开源出来。后来经过很多搜索确认,知道了几个事实:那么有没有可能用C#来控制Jlink呢?答案是,有!!! 解决思路在于,C#调用JLinkARM.dll里面的函数 这里转载下我认为很有意义的发现结合以上的几个发现,加上我自己的测试,我把我对接JLinkARM.dll的C#接口分享出来,不保证都能用,我只是测试了几个常用的功能,R

一只爱做笔记的码农 9161

linux docker位置查找,linux – 如何在Docker中获取依赖子图像列表?(1)

本书是获得了很多读者好评的Linux经典畅销书**《Linux从入门到精通》的第2版**。您应该能够查找父ID以f50f9524513f开头的图像,然后查找这些图像的子图像等.但是.Parent isn’t what you think.,所以在大多数情况下,您需要指定docker图像 – 以上所有才能使其工作,那么你也将获得所有中间层的图像ID.需要《Linux入门到精通》、《linux系统移植》、《Linux驱动开发入门实战》、《Linux开源网络全栈》电子书籍及教程的工程师朋友们劳烦您转发+评论。

2301_77118221的博客 893

STM32Cube高效开发教程<高级篇><FreeRTOS>(一)-----FreeRTOS基础

一、 FreeRTOS概述声明:本人水平有限,博客可能存在部分错误的地方,请广大读者谅解并向本人反馈错误。本专栏博客参考《STM32Cube高效开发教程(高级篇)》,有意向的读者可以购买正版书籍辅助学习,本书籍由王维波老师、鄢志丹老师、王钊老师倾力打造,书籍内容干货满满。写在前面:今天就算正式开始高级篇的博客编写了,我本人也是第一次学习FreeRTOS,所以整体的进度会比较慢,博客更新可能不太会及时,希望大家原谅。一、 FreeRTOS概述。

我的博客 1855

汽车UDS诊断详解及Vector相关工具链使用说明——1.1 应用层协议整体介绍

本文我们先从整体的维度来介绍一下应用层协议,每个UDS服务都遵循本文中的协议。 一、SI(Service ID) SI是UDS指令的第一个字节,我们第一篇文章中提到的10等服务就是指这个服务的SI=0x10,它是服务的标识,每个服务的SI都是唯一的。 ...

weixin_42967006的博客 5481

linux怎么监控特定进程,Shell脚本实现监视指定进程的运行状态

在之前的博客中,曾经写了自动化测试程序的实现方法,现在开发者需要知道被测试的进程(在此指运行在LINUX上的主进程的)在异常退出之前的进程的运行状态,例如内存的使用率、CPU的使用率等。现用shell脚本实现指定进程的运行状态。直接上代码。#!/bin/shecho "`date`"echo "Start $0---------"echo ""#每十秒监视一下sec=10#取得指定进程名为main...

weixin_31727937的博客 760

【项目实战】分布式日志系统 之 Exactly-once 语义:确保数据处理的精确性

在分布式系统的数据传输与处理中,是一种核心可靠性保障,其目标是确保数据“仅被处理一次”——既不重复(避免多次处理),也不遗漏(避免未处理)。与,二者共同保障数据处理的精确性。Exactly-once 语义是分布式系统中数据可靠性的高级目标,其核心通过“幂等设计”(解决重复问题)和“分布式事务”(解决原子性问题)实现。在实际应用中,常结合 At-Least-Once 语义与幂等性,或通过事务 API 与唯一 ID 去重的组合,平衡可靠性与系统性能。

奶爸的编程之路,也就一周冷个三天 174

使用shell脚本对Linux系统和进程资源进行监控

原文地址:http://www.ibm.com/developerworks/cn/linux/l-cn-shell-monitoring/ 检查进程是否存在 在 对进程进行监控时,我们一般需要得到该进程的 ID,进程 ID 是进程的唯一标识,但是有时可能在服务器上不同用户下运行着多个相同进程名的进程,下面的函数 GetPID 给出了获取指定用户下指定进程名的进程 ID 功能(目前只...

dechuannao3731的博客 662

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

使用Shell脚本对Linux系统和进程资源进行监控

发表于2012-06-26 08:58|4303次阅读| 来源IBM开发者社区|1 条评论| 作者于东海,宋波,池辰 ShellLinux脚本 摘要:Shell语言对于接触Linux的人来说都比较熟悉,它是系统的用户界面,提供了用户与内核进行交互操作的一种接口。本文我们以Bash做为实例总结了使用Shell对系统和进程资源进行监控的一些内容,希望对您能有帮助。 Shell语言对于

mayongmsss的专栏 642

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

使用 shell 脚本对 Linux 系统和进程资源进行监控

Shell 简介 Shell 语言对于接触 LINUX 的人来说都比较熟悉,它是系统的用户界面,提供了用户与内核进行交互操作的一种接口。它接收用户输入的命令并把它送入内核去执行。实际上 Shell 是一个命令解释器,它解释由用户输入的命令并且把它们送到内核。它没有一般编程语言的“编译 - 链接 - 运行”过程。不仅如此,Shell 有自己的编程语言用于对命令的编辑,它允许用户编...

aodiyu3146的博客 160

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

Shell脚本实现Linux系统和进程资源监控

在服务器运维过程中,经常需要对服务器的各种资源进行监控,例如:CPU的负载监控,磁盘的使用率监控,进程数目监控等等,以在系统出现异常时及时报警,通知系统管理员。本文介绍在Linux系统下几种常见的监控需求及其shell脚本的编写。文章目录:1.Linux使用 Shell 检查进程是否存在 2.Linux使用 Shell检测进程 CPU 利用率 3.Linux使用 Shell检测进程内存使用量 4.Linux使用 Shell检测进程句柄使用量 5.Linux使用 Shell查看某个 TCP 或 UDP 端口是

极客云曦前端 2564

linux shell脚本监控进程是否存在

用shell脚本监控进程是否存在 不存在则启动的实例,先上代码干货:12345678#!/bin/shps -fe|grep processString |grep -v grepif [ $? -ne 0 ]thenecho "start process....."elseecho "runing....."fi#####processString 表示进程特征字符串,能够查询到唯一进程的特征字...

T_Janey 1072

【转】使用Shell脚本对Linux系统和进程资源进行监控

原地址:http://www.csdn.net/article/2012-06-26/2806898 摘要:Shell语言对于接触Linux的人来说都比较熟悉,它是系统的用户界面,提供了用户与内核进行交互操作的一种接口。本文我们以Bash做为实例总结了使用Shell对系统和进程资源进行监控的一些内容,希望对您能有帮助。 Shell语言对于接触Linux的人来说都比较熟悉

xth6314的专栏 799
上一篇: 多线程打包分包
下一篇: 通用卡证信息高精度识别流程 OCR 文本检测 文本识别 身份证 银行卡
蛇胆隆力奇
博客等级 码龄13年 15粉丝 41原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值