In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Preface
Viewing process: divided into dynamic viewing and dynamic viewing
Control process: mainly to shut down the process, you can close the specified process according to the conditions, and all processes can be closed.
At one-time task setting
Crontab periodic task setting
First: the relationship between program and process. 1. Program
Executable code and data stored in media such as hard drives, CDs, etc.
Statically saved code 2, process
Program code running in CPU and memory
Dynamically executed code
Parent and child processes
-each process can create one or more processes
3. The relationship among programs, processes and threads.
An application can contain one or more application processes
A process contains one or more threads
A thread is the smallest unit that performs an operation.
Example:
Application = Factory
Process = workshop
Thread = worker
Highly concurrent processing depends on multithreaded operations
Two: view static process information ps2.1 ps command
When you execute a command without any suboptions directly, only the processes that are open in the current user session are displayed
[root@localhost ~] # ps PID TTY TIME CMD 4898 pts/1 00:00:00 bash 5249 pts/1 00:00:00 ps2.2 ps aux command
View static process statistics
[root@localhost ~] # ps aux [root@localhost ~] # ps auxUSER PID% CPU% MEM VSZ RSS TTY STAT START TIME COMMANDroot 1 0.0 0.3 128212 6836? Ss 10:43 0:01 / usr/lib/systemd/sroot 2 0.0 0.0 0 0? S 10:43 0:00 [kthreadd] root 3 0.0 0.0 00? S 10:43 0:00 [ksoftirqd/0] root 5 0.0 0.0 00? S
< 10:43 0:00 [kworker/0:0H]root 6 0.0 0.0 0 0 ? S 10:43 0:00 [kworker/u256:0]root 7 0.0 0.0 0 0 ? S 10:43 0:00 [migration/0]root 8 0.0 0.0 0 0 ? S 10:43 0:00 [rcu_bh]root 9 0.0 0.0 0 0 ? R 10:43 0:00 [rcu_sched]root 10 0.0 0.0 0 0 ? S 10:43 0:00 [watchdog/0]root 12 0.0 0.0 0 0 ? S 10:43 0:00 [kdevtmpfs]root 13 0.0 0.0 0 0 ? S< 10:43 0:00 [netns]root 14 0.0 0.0 0 0 ? S 10:43 0:00 [khungtaskd] a 显示当前终端下的所有进程信息,包括其他用户的进程。与x结合时将显示系统中所有的进程信息 不带- u 使用已用户为主的格式输出进程信息,不带- x 显示当前用户在所有中终端下的进程信息,不带- -e 显示系统中的所有进程信息 -l 使用长格式(long)显示进程信息 -f 使用完整的(full/)格式显示进程信息 竖着读的一列叫做字段,也叫做属性 字段解释USER启动该进程的用户账号的名称PID该进程在系统中的数字ID进程号,在当前系统中是唯一的%CPUCPU的资源渣用率%MEM内存的占用率VSZ虚拟内存,在进程启用完毕后会释放归0RSS占用物理内存的大小(常驻内存)TTY显示了该进程在哪个终端上运行,是在本地终端还是在远程终端。"?"表示未知或者不需要终端STAT进程状态,S代表休眠,R代表运行,Z代表僵死,s代表父进程, pgrep -U root | wc -l >/ opt/test.txtat > 'ctrl+d, submit tasks' job 1 at Tue Nov 12 17:33:00 2019 [root@localhost mnt] # atq 'check the configured tasks, and there is no' [root@localhost mnt] # date 'look date' Tuesday, November 12, 2019, 17:33:59 CST 'has passed the time' [root@localhost mnt] # cat / opt/test.txt180'
The time of this command must be after the current time
Date gets the current system time
At > followed by commands to be executed at this time in the future
Eot is to press ctrl + D key to submit a task.
You can also view it on atq to see a list of tasks to be assigned for execution.
Case study: automatically shut down the current system at 21: 30 on the same day
[root@localhost mnt] # at 21:30 2019-11-12at > shutdown-h now 'shut down the current system' at > job 2at Tue Nov 12 21:30:00 2019 [root@localhost mnt] # atq2 Tue Nov 12 21:30:00 2019 a root [root@localhost mnt] # atrm 2 'Delete scheduled task 2' [root@localhost mnt] # atq
Atrm deletes scheduled tasks
8.2 the crontab command repeatedly executes user-specified command operations according to a preset time period (time-sharing, day, month and week). It belongs to periodic scheduled tasks. The main settings file is the global configuration file, located in the file: / etc/crontab system default settings, located in the directory: / etc/cron.*/ user-defined settings Located in file: / var/spool/cron/ username 8.3 manage cron scheduled task edit cron scheduled task [root@localhost mnt] # crontab-e [- u username] View scheduled task [root@localhost mnt] # crontab-l [- u username] Delete scheduled task [root@localhost mnt] # crontab-r [- u username]
E edit, create a scheduled task
-l list list
-r Delete
8.4 Special representation of time values symbolic interpretation * indicates all times within the range of the location, indicates multiple discontinuous time points of the interval-indicates a continuous time range / n the time frequency of the specified interval is n8.5 application example explains 0 17 1-5 Monday to Friday 17: 00 30 8 1 1 3 every day 5 every Monday, Wednesday and Friday 08:30 0 8-18 crontab 2 * every day between 8 o'clock and 18:00 every two hours 0 / 3 every three days [root@localhost mnt] # crontab-e "/ tmp/crontab.16EW6c" 1L 37C 'automatically enter the configuration in this file' * / 2 * ps aux | wc-l > / ps.txt' 'enter the configuration in single quotes': wq 'save exit' no crontab for root-using an empty onecrontab: installing new crontab [root@localhost mnt] # crontab-l 'View scheduled tasks' * / 2 * ps aux | wc-l > / ps. Txt IX. Summary commands for viewing processes (ps, top, pgrep, pstree) process control starts the process scheduling process (Ctrl+z key combination, jobs, bg, fg) terminates the process (kill, killall, pkill) at command sets the configuration fields for scheduled tasks crontab scheduled tasks
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.