Home php教程 PHP源码 如何用Linux 查看服务的状态与进程

如何用Linux 查看服务的状态与进程

May 23, 2016 am 08:39 AM
linux

这篇文章主要讲了如何用Linux 查看服务的状态与进程,有一定的参考价值,感兴趣的朋友可以看看。

指令(instruction): 
计算机实际上可以做的事情实质上非常简单,比如计算两个数的和,再比如在内存中寻找到某个地址等等。这些最基础的计算机动作被称为指令 (instruction)。 

程序(program): 
这样一系列指令的所构成的集合。通过程序,我们可以让计算机完成复杂的操作。程序大多数时候被存储为可执行的文件。这样一个可执行文件就像是一个菜谱,计算机可以按照菜谱作出可口的饭菜。 

进程(process): 
进程是程序的一个具体实现。只有食谱没什么用,我们总要按照食谱的指点真正一步步实行,才能做出菜肴。进程是执行程序的过程,类似于按照食谱,真正去做菜的过程。同一个程序可以执行多次,每次都可以在内存中开辟独立的空间来装载,从而产生多个进程。不同的进程还可以拥有各自独立的IO接口。 

可以使用$ps命令来查询正在运行的进程; 
参数:ps的参数非常多, 在此仅列出几个常用的参数并大略介绍含义 
-A 列出所有的进程(等价于-e) 
-w 显示加宽可以显示较多的资讯 
-au 显示较详细的资讯 
-aux 显示所有包含其他使用者的行程

服务(service) 
服务相当于支持系统运行的一些必要程序,默默运行在系统后台的,他可以为应用程序提供一些更有特色的东西,比如播放MP3,开启一个播放MP3的服务,用户点击开始按钮通知服务开启,点击关闭按钮通知服务关闭,如果你禁用这个服务,那别人想播放MP3那是不行的,而且服务之间是有可能互相依靠的。

服务与进程? 
有人回答说:你开启了哪个服务任务管理器里就会有哪个服务相对应的进程; 
有人说:服务是每次开机会按照服务启动模式启动的进程的集合,服务可能包括很多进程。而且启动的进程可能是互相交叉的。

linux查看服务: 

一、利用进程来查看 
命令里 ps -aux | grep xxx 是查看某个进程或者服务是否存在。 

二、利用services命令 
1.查看单个服务的运行状态: 
service 服务名 status 
如:[root@localhost ~]# service sshd status 
openssh-daemon (pid 3701) 正在运行… 
2.查看所有服务的运行状态: 
service –status -all 

三、利用chkconfig配置工具(并没有试过) 
(在Ubuntu中是没有chkconfig命令的,可以用update-rc.d 来代替。 
Ubuntu或者Debian系统中update-rc.d命令,是用来更新系统启动项的脚本。这些脚本的链接位于/etc/rcN.d/目录,对应脚本 位于/etc/init.d/目录。在了解update-rc.d命令之前,你需要知道的是有关Linux 系统主要启动步骤,以及Ubuntu中运行级别的知识。) 
1.查看单个服务的运行状态: 
chkconfig 服务名 status 
2.查看所有服务的运行状态 
chkconfig –list 
3.关闭或开启服务状态: 
chkconfig –level 345 nscd off/on 
3.关闭或开启服务状态: 
chkconfig –level 345 nscd off/on 
4.增加服务: 
chkconfig –add xxx ( 注意:服务脚本必须存放在 /etc/init.d/目录下) 
如mysqld 
[root@www mysql-5.1.59]#cp support-files/mysql.server etc/init.d/mysqld 
chkconfig mysqld on (各等级为ON,各等级为2345等级) 
这样就会以系统服务的形式启动了 
5.删除服务: 
chkconfig –del XXX 
runlevel 查看当前等级。 
注意:运行级别就是操作系统正在运行的功能级别。

【相关教程推荐】

1.  php编程从入门到精通全套视频教程
2.  php从入门到精通
3. bootstrap教程

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1665
14
PHP Tutorial
1269
29
C# Tutorial
1249
24
Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

vscode Previous Next Shortcut Key vscode Previous Next Shortcut Key Apr 15, 2025 pm 10:51 PM

VS Code One-step/Next step shortcut key usage: One-step (backward): Windows/Linux: Ctrl ←; macOS: Cmd ←Next step (forward): Windows/Linux: Ctrl →; macOS: Cmd →

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

How to run sublime after writing the code How to run sublime after writing the code Apr 16, 2025 am 08:51 AM

There are six ways to run code in Sublime: through hotkeys, menus, build systems, command lines, set default build systems, and custom build commands, and run individual files/projects by right-clicking on projects/files. The build system availability depends on the installation of Sublime Text.

What is the main purpose of Linux? What is the main purpose of Linux? Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

laravel installation code laravel installation code Apr 18, 2025 pm 12:30 PM

To install Laravel, follow these steps in sequence: Install Composer (for macOS/Linux and Windows) Install Laravel Installer Create a new project Start Service Access Application (URL: http://127.0.0.1:8000) Set up the database connection (if required)

git software installation git software installation Apr 17, 2025 am 11:57 AM

Installing Git software includes the following steps: Download the installation package and run the installation package to verify the installation configuration Git installation Git Bash (Windows only)

See all articles