热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

bash判断进程存在的3种方法

文章标题:bash判断进程存在的3种方法。Linux是中国IT实验室的一个技术频道。包含桌面应用,Linux系统管理,内核研究,嵌入式系统和开源等一些基本分类

当前系统中的进程:
    apple@ubuntu:~$ ps -ef
    UID        PID  PPID  C STIME TTY          TIME CMD
    root         1     0  0 13:57 ?        00:00:02 /sbin/init
    root         2     0  0 13:57 ?        00:00:00 [kthreadd]
    root         3     2  0 13:57 ?        00:00:00 [migration/0]
    root         4     2  0 13:57 ?        00:00:00 [ksoftirqd/0]
    root         5     2  0 13:57 ?        00:00:00 [watchdog/0]
    root         6     2  0 13:57 ?        00:00:00 [migration/1]
    root         7     2  0 13:57 ?        00:00:00 [ksoftirqd/1]
    root         8     2  0 13:57 ?        00:00:00 [watchdog/1]
    root         9     2  0 13:57 ?        00:00:00 [events/0]
    root        10     2  0 13:57 ?        00:00:00 [events/1]
    root        11     2  0 13:57 ?        00:00:00 [khelper]
    root        12     2  0 13:57 ?        00:00:00 [kstop/0]
    root        13     2  0 13:57 ?        00:00:00 [kstop/1]
    root        14     2  0 13:57 ?        00:00:00 [kintegrityd/0]
    root        15     2  0 13:57 ?        00:00:00 [kintegrityd/1]
    root        16     2  0 13:57 ?        00:00:00 [kblockd/0]
    root        17     2  0 13:57 ?        00:00:00 [kblockd/1]
    root        18     2  0 13:57 ?        00:00:00 [kacpid]
    root        19     2  0 13:57 ?        00:00:00 [kacpi_notify]
    root        20     2  0 13:57 ?        00:00:00 [cqueue]
    root        21     2  0 13:57 ?        00:00:00 [ata/0]
    root        22     2  0 13:57 ?        00:00:00 [ata/1]
    root        23     2  0 13:57 ?        00:00:00 [ata_aux]
    root        24     2  0 13:57 ?        00:00:00 [ksuspend_usbd]
    root        25     2  0 13:57 ?        00:00:00 [khubd]
    root        26     2  0 13:57 ?        00:00:00 [kseriod]
    root        27     2  0 13:57 ?        00:00:00 [kmmcd]
    root        28     2  0 13:57 ?        00:00:00 [btaddconn]
    root        29     2  0 13:57 ?        00:00:00 [btdelconn]
    root        30     2  0 13:57 ?        00:00:00 [pdflush]
    root        31     2  0 13:57 ?        00:00:00 [pdflush]
    root        32     2  0 13:57 ?        00:00:00 [kswapd0]
    root        33     2  0 13:57 ?        00:00:00 [aio/0]
    root        34     2  0 13:57 ?        00:00:00 [aio/1]
    root        35     2  0 13:57 ?        00:00:00 [ecryptfs-kthrea]
    root        38     2  0 13:57 ?        00:00:00 [pciehpd]
    root        39     2  0 13:57 ?        00:00:00 [scsi_eh_0]
    root        40     2  0 13:57 ?        00:00:00 [scsi_eh_1]
    root        41     2  0 13:57 ?        00:00:00 [kstriped]
    root        42     2  0 13:57 ?        00:00:00 [kmpathd/0]
    root        43     2  0 13:57 ?        00:00:00 [kmpathd/1]
    root        44     2  0 13:57 ?        00:00:00 [kmpath_handlerd]
    root        45     2  0 13:57 ?        00:00:00 [ksnapd]
    root        46     2  0 13:57 ?        00:00:00 [kondemand/0]
    root        47     2  0 13:57 ?        00:00:00 [kondemand/1]
    root        48     2  0 13:57 ?        00:00:00 [krfcommd]
    root       256     2  0 13:57 ?        00:00:00 [mpt_poll_0]
    root       717     2  0 13:57 ?        00:00:00 [scsi_eh_2]
    root       753     2  0 13:57 ?        00:00:00 [kdmflush]
    root       764     2  0 13:57 ?        00:00:00 [kdmflush]
    root       795     2  0 13:57 ?        00:00:00 [kjournald]
    root       915     1  0 13:57 ?        00:00:00 /sbin/udevd --daemon
    root      1617     2  0 13:57 ?        00:00:00 [kpsmoused]
    root      2166     1  0 13:57 tty4     00:00:00 /sbin/getty 38400 tty4
    root      2167     1  0 13:57 tty5     00:00:00 /sbin/getty 38400 tty5
    root      2172     1  0 13:57 tty2     00:00:00 /sbin/getty 38400 tty2
    root      2173     1  0 13:57 tty3     00:00:00 /sbin/getty 38400 tty3
    root      2174     1  0 13:57 tty6     00:00:00 /sbin/getty 38400 tty6
    root      2244     1  0 13:57 ?        00:00:00 /usr/sbin/acpid -c /etc/acpi/eve
    root      2259     1  0 13:57 ?        00:00:00 /usr/sbin/syslog-ng -p /var/run/
    105       2279     1  0 13:57 ?        00:00:00 /bin/dbus-daemon --system
    root      2311     1  0 13:58 ?        00:00:00 /usr/sbin/incrond -f /etc/incron
    root      2381     1  0 13:58 ?        00:00:00 dhclient3 -e IF_METRIC=100 -pf /
    root      2442     1  0 13:58 ?        00:00:00 /usr/sbin/sshd
    root      2453     1  0 13:58 ?        00:00:00 /usr/lib/postfix/master
    postfix   2465  2453  0 13:58 ?        00:00:00 pickup -l -t fifo -u -c
    postfix   2468  2453  0 13:58 ?        00:00:00 qmgr -l -t fifo -u
    108       2472     1  0 13:58 ?        00:00:00 /usr/sbin/hald
    root      2475     1  0 13:58 ?        00:00:00 /usr/sbin/console-kit-daemon
    root      2538  2472  0 13:58 ?        00:00:00 hald-runner
    root      2567  2538  0 13:58 ?        00:00:00 hald-addon-input: Listening on /
    root      2594  2538  0 13:58 ?        00:00:00 hald-addon-storage: polling /dev
    root      2595  2538  0 13:58 ?        00:00:00 hald-addon-storage: no polling o
    108       2600  2538  0 13:58 ?        00:00:00 hald-addon-acpi: listening on ac
    daemon    2647     1  0 13:58 ?        00:00:00 /usr/sbin/atd
    root      2672     1  0 13:58 ?        00:00:00 /usr/sbin/cron
    root      2691     1  0 13:58 tty1     00:00:00 /sbin/getty 38400 tty1
    root      2994  2442  0 14:11 ?        00:00:00 sshd: apple [priv]
    apple     3003  2994  0 14:11 ?        00:00:00 sshd: apple@pts/0
    apple     3004  3003  1 14:11 pts/0    00:00:00 -bash
    apple     3024  3004  0 14:11 pts/0    00:00:00 ps -ef

[1] [2] 下一页


推荐阅读
  • 在Kubernetes上部署JupyterHub的步骤和实验依赖
    本文介绍了在Kubernetes上部署JupyterHub的步骤和实验所需的依赖,包括安装Docker和K8s,使用kubeadm进行安装,以及更新下载的镜像等。 ... [详细]
  • 在Docker中,将主机目录挂载到容器中作为volume使用时,常常会遇到文件权限问题。这是因为容器内外的UID不同所导致的。本文介绍了解决这个问题的方法,包括使用gosu和suexec工具以及在Dockerfile中配置volume的权限。通过这些方法,可以避免在使用Docker时出现无写权限的情况。 ... [详细]
  • 成功安装Sabayon Linux在thinkpad X60上的经验分享
    本文分享了作者在国庆期间在thinkpad X60上成功安装Sabayon Linux的经验。通过修改CHOST和执行emerge命令,作者顺利完成了安装过程。Sabayon Linux是一个基于Gentoo Linux的发行版,可以将电脑快速转变为一个功能强大的系统。除了作为一个live DVD使用外,Sabayon Linux还可以被安装在硬盘上,方便用户使用。 ... [详细]
  • 本文介绍了在Android Studio中使用命令行build gradle的方法,并解决了一些常见问题,包括手动配置gradle环境变量和解决External Native Build Issues的方法。同时提供了相关参考文章链接。 ... [详细]
  • 本文介绍了Linux Shell中括号和整数扩展的使用方法,包括命令组、命令替换、初始化数组以及算术表达式和逻辑判断的相关内容。括号中的命令将会在新开的子shell中顺序执行,括号中的变量不能被脚本余下的部分使用。命令替换可以用于将命令的标准输出作为另一个命令的输入。括号中的运算符和表达式符合C语言运算规则,可以用在整数扩展中进行算术计算和逻辑判断。 ... [详细]
  • 本文介绍了Shell中for命令的基本格式和用法,通过提供一个值列表来迭代执行一系列命令。同时还介绍了如何读取列表中的值,并给出了for命令与其他命令的结合使用示例。 ... [详细]
  • 【shell】网络处理:判断IP是否在网段、两个ip是否同网段、IP地址范围、网段包含关系
    本文介绍了使用shell脚本判断IP是否在同一网段、判断IP地址是否在某个范围内、计算IP地址范围、判断网段之间的包含关系的方法和原理。通过对IP和掩码进行与计算,可以判断两个IP是否在同一网段。同时,还提供了一段用于验证IP地址的正则表达式和判断特殊IP地址的方法。 ... [详细]
  • 树莓派语音控制的配置方法和步骤
    本文介绍了在树莓派上实现语音控制的配置方法和步骤。首先感谢博主Eoman的帮助,文章参考了他的内容。树莓派的配置需要通过sudo raspi-config进行,然后使用Eoman的控制方法,即安装wiringPi库并编写控制引脚的脚本。具体的安装步骤和脚本编写方法在文章中详细介绍。 ... [详细]
  • 本文总结了Linux下多线程执行shell脚本的4种方法,包括切换到工作目录执行、使用绝对路径执行、直接使用bash或sh执行。同时介绍了为什么需要加上"./"来执行脚本的原因。 ... [详细]
  • 一、修改注册表去掉桌面图标小箭头1按下win+R组合快捷键,打开windows10系统的“运行”窗口,输入“regedit”,打开注册表编辑器,找到HKEY_CLASSES_ROOT\lnkfi ... [详细]
  • Django + Ansible 主机管理(有源码)
    本文给大家介绍如何利用DjangoAnsible进行Web项目管理。Django介绍一个可以使Web开发工作愉快并且高效的Web开发框架,能够以最小的代价构建和维护高 ... [详细]
  • hadoop1.2.1文档中这样写:Nowcheckthatyoucansshtothelocalhostwithoutapassphrase:$sshlocalhostIfyou ... [详细]
  • 本文由编程笔记#小编为大家整理,主要介绍了markdown[软件代理设置]相关的知识,希望对你有一定的参考价值。 ... [详细]
  • 现在比较流行使用静态网站生成器来搭建网站,博客产品着陆页微信转发页面等。但每次都需要对服务器进行配置,也是一个重复但繁琐的工作。使用DockerWeb,只需5分钟就能搭建一个基于D ... [详细]
  • DockerDataCenter系列(四)-离线安装UCP和DTR,Go语言社区,Golang程序员人脉社 ... [详细]
author-avatar
长沙祛疤--欣奕除疤_998
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有