当前位置:网站首页>Process management and task management

Process management and task management

2022-08-10 02:32:00 sologuai

1. View process information

1. The ps command to view the process statically

Common options:

When directly executing the ps command without any options, only the processes opened in the current user session will be displayed

  • View the current system process

  • STAT:

    • D: Sleep state that cannot be awakened;

    • R:running status;

    • S: in sleep state, can be woken up;

    • T: stop state, it may be suspended in the background or the process is in a trace debugging state;

    • Z: Zombie factory process, the process has been terminated, but some programs are still in memory, but its parent process cannot terminate it normally

Zombie process: A zombie process is when the child process ends before the parent process, and the parent process does not recycle the child process and release the resources occupied by the child process. At this time, the child process will become a zombie process.If the parent process exits first, the child process is taken over by init, and after the child process exits, init will reclaim the related resources occupied by it.

2.ps -elf command

3.ps-T view thread

View current thread

4. Dynamic view top command

View current thread

5.pgrep command - query process PID information according to specific conditions

Display the process name and its process ID of the process that contains the log

6.pstree command view process tree

7. Manual start process of control process

  • Foreground startup: the program directly executed by the user entering a command;

  • Start in the background: add an "&" sign at the end of the command line

When using the cp command to create an image file from a CD, it takes a long time to copy a lot of data, so you can combine the "&" symbol to run the copy operation in the background, so that the user can continue to execute other commandsAction

8. Front-end and back-end scheduling of processes

  • Ctrl + Z key combination: Suspend the current process, that is, transfer 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, you can specify the task sequence number

9. Terminate the process

Ctrl + C: Interrupt the command being executed

kill, killall command

  • kill is used to kill the process with the specified PID number

  • killall is used to kill all processes associated with the specified name

  • -9 option for force termination

Pkill command two options

Second, scheduled task management

1. Use the at command to set a one-time scheduled task

at [HH:MM] [yyyy-mm-dd] # execute today without the year, month and dayatq #View unexecuted one-time scheduled tasksatrm #delete task

2. Use the crontab command to set up periodic scheduled tasks

crontab command

  • Repeatedly execute the command operation specified by the user according to the preset time period (minutes, hours, days....)

  • It belongs to a periodic scheduled task

Edit scheduled taskscrontab -e [-u username]View scheduled taskscrontab -l [-u username] ​delete scheduled taskcrontab -r [-u username] 

Each asterisk (*) represents a different concept of time:

Special representation of time values:

原网站

版权声明
本文为[sologuai]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/222/202208100104176002.html