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

Chapter 11 Planning tasks-centos7.5 knowledge

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

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

I. the relationship between programs and processes

Ps

program

Executable code and data stored in media such as hard drives, CDs, etc.

Statically saved code

Process

Program code running in CPU and memory

Dynamically executed code

Parent and child processes

Each process can create one or more processes

View process information ps

Ps command

View static process statistics

Ps aux or ps-elf

Top command

-View dynamic process ranking information

You can properly introduce the command keys of the top tool: P, M, N, h, Q

Press P key to sort the list of processes according to CPU usage

Press M key to sort according to memory usage

Press the N key to sort according to the startup time

Press the h key to get online help information for top programs.

Press Q key to exit the top program normally.

Use the spacebar to force the update process status display

Pgrep command

Query process PID information based on specific conditions

[root@localhost ~] # pgrep-l "log"

2538 rsyslogd

2113 mcelog

[root@localhost] # pgrep-l-U teacher-t tty1

27483 bash

27584 vim

Pstree-aup

Pstree command

-list process information in a tree structure

Pstree-aup

Pstree-ap teacher

-a: display complete information

-u: list the corresponding user name

-p: list the corresponding PID number

Second, the starting mode of the process

Start by hand

-Front desk startup: the user enters commands and executes the program directly

-background startup: add a "&" symbol at the end of the command line

-scheduling startup: scheduling tasks

-use the at command to set up one-time scheduled tasks

Foreground and background scheduling of processes

Ctrl+Z key combination

-suspend the current process, that is, call it to the background and stop execution

Jobs command

-View the list of tasks in the background

Fg command

-restore the background process to the foreground, and specify the task sequence number

Root@localhost ~] # jobs

[1]-Stopped cp / dev/cdrom mycd.iso

[2] + Stopped top

[root@localhost ~] # fg 1

Terminate the operation of the process

Ctrl+C key combination

-interrupt a command that is being executed

Kill 、

Killall command

-kill is used to terminate the process with a specified PID number

-killall is used to terminate all processes with the specified name

-- 9 option for forced termination

Pkill command

-terminate the corresponding process according to specific conditions

-Common command options

-U: terminates the process according to the user name to which the process belongs

-t: terminate the corresponding process according to the terminal where the process is located

[root@localhost ~] # pgrep-l-U "hackli"

3045 bash

[root@localhost] # pkill-9-U "hackli"

[root@localhost ~] # pgrep-l-U "hackli"

Planned task management

At command (press ctrl+d to save the task)

-schedule tasks at once

At [HH:MM] [yyyy-mm-dd]

[root@localhost ~] # date

Sun May 7 10:33:13 EDT 2017

[root@localhost] # at 10:35 2017-05-07

At > pgrep-U root | wc-l > / tmp/ps.root

At >

Job 1 at Sun May 7 10:35:00 2017

[root@localhost ~] # cat / tmp/ps.root

202

Root@localhost ~] # at 21:30

At > shutdown-h now

At >

Job 2 at Sun May 7 21:30:00 2017

[root@localhost ~] # atq

2 Sun May 7 21:30:00 2017 a root

Query tasks defined by at

Cd / var/spool/at/

Ls-l

[root@localhost ~] # atrm 2

[root@localhost ~] # atq

Use the crontab command to set up periodic scheduled tasks

Scheduled Task Management crond

Crontab command

-according to the pre-set time period (minutes, hours, days …... ) repeat the command operation specified by the user

-is a periodic scheduled task

-main settings file

Global configuration file, located in file: / etc/crontab

The default setting of the system is located in the directory: / etc/cron.*/

User-defined settings, located in the file: / var/spool/cron/ username

Manage cron scheduled tasks

-Edit scheduled tasks

Crontab-e [- u user name] Edit scheduled tasks

Crontab-l [- u user name] lists view scheduled tasks

Crontab-r [- u username] clears scheduled tasks

Format of crontab task configuration

A special representation of time value

-* indicates any time within this range

-, representing multiple discontiguous points in time at intervals

-- represents a continuous time range

-/ specify the time frequency of the interval

Application example

-0 17 * 1-5 Monday to Friday 17:00 every day

-308 * * 1pyrrine 3505 08:30 on Mondays, Wednesdays and Fridays

-0 8-18 stroke 2 * every 2 hours between 8 and 18:00

-0 * / 3 * * every 3 days

Assignment:

1. Schedule at 15:30 on Wednesday, and output the date and time to / tmp/dateaudit.txt.

2. Write out 3 commands that view the systemd status of the specified running process and their usage.

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

Network Security

Wechat

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

12
Report