Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the command to restart a process in linux

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces you how to use the command to restart the process in linux, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.

#! / bin/shps-ef | grep [p] ython | cut-c 9-15 | xargs kill-s 9python a.py > / dev/null & python b.py > / dev/null & python c.py > / dev/null

Show all processes-> filter python processes-> propose process numbers-> format process numbers and kill processes according to process numbers

Ps: show a process

-A displays all programs.

-e this parameter has the same effect as specifying the "A" parameter.

-f displays the UID,PPIP,C and STIME fields.

The grep command is to find

The middle | is the pipe command, which means that the ps command is executed simultaneously with grep

UID PID PPID C STIME TTY TIME CMD

The significance of the relevant information:

UID: the program is owned by the UID

PID: that's the ID of this program.

PPID: the ID of its parent program

C: percentage of resources used by CPU

STIME: system startup time

TTY: the terminal location of the login

TIME: used CPU time

CMD: what are the instructions issued?

Why ps aux | grep python will have the result of grep-color=auto python, because grep itself is also a process, and ps will also display the information of the grep process.

Why the grep process itself does not appear in ps aux | grep [p] ython, because the parameter of the grep process is grep-- color=auto [p] ython, while the grep [p] ython regular matches the string 'python',' and the regular expression'[p] ython' does not match the string'[p] ython', so naturally the grep process itself does not appear. 9-15

Root four characters, followed by four spaces

Intercept from the 9th character to the 15th character (not included)

Instructions for use:

The cut command cuts bytes, characters, and fields from each line of the file and writes them to standard output.

If you do not specify the File parameter, the cut command reads standard input. One of the-b,-c, or-f flags must be specified.

Parameters:

-b: split in bytes. These byte positions ignore multibyte character boundaries unless the-n flag is also specified.

-c: split on a character basis.

-d: custom delimiter, default to tab.

-f: used with-d to specify which area to display.

-n: unsplit multibyte characters. Used only with the-b flag. If the last byte of the character falls on the List parameter indicated by the-b flag

Within the range, the character will be written out; otherwise, the character will be excluded

Xargs can convert single-line or multi-line text input to other formats, such as multi-line to single-line, single-line to multi-line. # cat test.txta b cd e f gh ij k lm n multi-line input and single-line output: # cat test.txt | xargsa b cd e fg h ij k lm Nmurn option multi-line output: # cat test.txt | xargs-n3a b cd e fg h ij k lm n on how to use commands in linux to restart the process is shared here. I hope the above content can be helpful to everyone and learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report