[Comprehensive explanation of Linux commands] 185. Operation guide for using the skill command to freeze the process

Article directory

  • skill
    • Additional information
    • grammar
    • Options
    • Example
  • Learn `python` from scratch

skill

Send a signal to the selected process to freeze the process

Supplementary instructions

The skill command is used to send a signal to the selected process and freeze the process. This command is not commonly used by beginners, but may be used when it comes to system service optimization.

Grammar

skill (option)

Options

  • -f: fast mode;
  • -i: Interactive mode, each operation requires confirmation;
  • -v: redundant mode;
  • -w: activate mode;
  • -V: Display version number;
  • -t: Specify the terminal number to start the process;
  • -u: Specify the user who starts the process;
  • -p: Specify the ID number of the process;
  • -c: Specify the name of the command to start the process.

Example

What should you do if you find a process that’s taking up a lot of CPU and memory, but you don’t want to stop it? Consider the following top command output:

top -c -p 16514
23:00:44 up 12 days, 2:04, 4 users, load average: 0.47, 0.35, 0.31
1 processes: 1 sleeping, 0 running, 0 zombie, 0 stopped
CPU states: cpu user nice system irq softirq iowait idle
           total 0.0% 0.6% 8.7% 2.2% 0.0% 88.3% 0.0%
Mem: 1026912k av, 1010476k used, 16436k free, 0k shrd, 52128k buff
                    766724k actv, 143128k in_d, 14264k in_c
Swap: 2041192k av, 83160k used, 1958032k free 799432k cached

  PID USER PRI NI SIZE RSS SHARE stat %CPU %MEM time CPU command
16514 oracle 19 4 28796 26M 20252 D N 7.0 2.5 0:03 0 oraclePRODB2...

Now that you confirmed that process 16514 is taking up a lot of memory, you can use the skill command to “freeze” it instead of stopping it.

skill-STOP 1

After that, check the top output:

23:01:11 up 12 days, 2:05, 4 users, load average: 1.20, 0.54, 0.38
1 processes: 0 sleeping, 0 running, 0 zombie, 1 stopped
CPU states: cpu user nice system irq softirq iowait idle
           total 2.3% 0.0% 0.3% 0.0% 0.0% 2.3% 94.8%
Mem: 1026912k av, 1008756k used, 18156k free, 0k shrd, 3976k buff
                    770024k actv, 143496k in_d, 12876k in_c
Swap: 2041192k av, 83152k used, 1958040k free 851200k cached

  PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND
16514 oracle 19 4 28796 26M 20252 T N 0.0 2.5 0:04 0 oraclePRODB2...

Now the CPU goes from 0% idle to 94% idle. The process is effectively frozen. After some time, you may want to wake up the process:

skill-CONT 16514

This method is useful if you want to temporarily freeze a process to make room for more important processes to complete.

This command is very versatile. If you want to stop all processes for the “oracle” user, just one command will do it:

skill -STOP oracle

You can use user, PID, command or terminal id as arguments. The following command stops all rman commands.

skill -STOP rman

As you can see, skill determines the parameters you enter (process ID, user ID, or command) and acts accordingly. This may cause problems in some cases: you may have a user and command with the same name. The best example is the “oracle” process, typically run by user “oracle”. Therefore, when you wish to stop a process named “oracle”, you would execute the following command:

skill -STOP oracle

All processes for user “oracle” are stopped, including sessions you might be using. To be very specific about executing a command, you can optionally specify the type of the argument using a new argument. To stop a command named oracle, execute the following command:

skill -STOP -c oracle

The snice command functions similarly to skill. But it is used to lower the priority of a process, not stop it. First, check the top output:

 PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND
    3 root 15 0 0 0 0 RW 0.0 0.0 0:00 0 kapmd
13680 oracle 15 0 11336 10M 8820 T 0.0 1.0 0:00 0 oracle
13683 oracle 15 0 9972 9608 7788 T 0.0 0.9 0:00 0 oracle
13686 oracle 15 0 9860 9496 7676 T 0.0 0.9 0:00 0 oracle
13689 oracle 15 0 10004 9640 7820 T 0.0 0.9 0:00 0 oracle
13695 oracle 15 0 9984 9620 7800 T 0.0 0.9 0:00 0 oracle
13698 oracle 15 0 10064 9700 7884 T 0.0 0.9 0:00 0 oracle
13701 oracle 15 0 22204 21M 16940 T 0.0 2.1 0:00 0 oracle

Now, lower the priority of the “oracle” process by four points. Note that the higher the value, the lower the priority.

snice + 4 -u oracle
 PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND
16894 oracle 20 4 38904 32M 26248 D N 5.5 3.2 0:01 0 oracle

Note that the NI column (nice value) is now 4 and the priority is now set to 20 instead of 15. This is very helpful for lowering priorities.

Learn python

from scratch

[Learn python from scratch] 92. Use Python’s requests library to send HTTP requests and process responses
[Learn python from scratch] 91. A simple web application that uses decorators and dictionaries to manage request paths
[Learn python from scratch] 93. Use dictionaries to manage request paths
[Learn python from scratch] 89. Use WSGI to build a simple and efficient web server
[Learn python from scratch] 88. Detailed explanation of WSGI interface: achieving simple and efficient web development
[Learn python from scratch] 87. Manually build Python implementation of HTTP server and multi-thread concurrent processing
[Learn python from scratch] 86. In-depth understanding of the HTTP protocol and its role in browser and server communication
[Learn python from scratch] 85. Application of parallel computing technology in Python process pool
[Learn python from scratch] 84. In-depth understanding of threads and processes
[Learn python from scratch] 83. Python multi-process programming and the use of process pools
[Learn python from scratch] 82. Implementation of chat program based on multi-threading
[Learn python from scratch] 81. Application of Python multi-thread communication and queue
[Learn python from scratch] 80. Thread access to global variables and thread safety issues
[Learn python from scratch] 79. Thread access to global variables and thread safety issues
[Learn python from scratch] 78. File download case
[Learn python from scratch] 77. TCP server programming and precautions
[Learn python from scratch] 76. Server and client: key components of network communication
[Learn python from scratch] 75. TCP protocol: a reliable connection-oriented transport layer communication protocol
[Learn python from scratch] 74. UDP network program: detailed explanation of port issues and binding information
[Learn python from scratch] 73. UDP network program-send data
[Learn python from scratch] 72. In-depth understanding of Socket communication and methods of creating sockets
[Learn python from scratch] 71. Network ports and their functions
[Learn python from scratch] 70. Network communication methods and their applications: from direct communication to routers connecting multiple networks
[Learn python from scratch] 69. Network communication and IP address classification analysis
[Learn python from scratch] 68. Greedy and non-greedy modes in Python regular expressions
[Learn python from scratch] 67. The re module in Python: regular replacement and advanced matching technology
[Learn python from scratch] 66. In-depth understanding of regular expressions: a powerful tool for pattern matching and text processing
[Learn python from scratch] 65. Detailed explanation of Python regular expression modifiers and their applications
[Learn python from scratch] 64. Detailed explanation of the use of re.compile method in Python regular expressions
[Learn python from scratch] 63. Introduction to the re.Match class and its attributes and methods in regular expressions
[Learn python from scratch] 62. Python regular expressions: a powerful string matching tool
[Learn python from scratch] 61. Detailed explanation and application examples of property attributes in Python
[Learn python from scratch] 60. Exploration generator: a flexible tool for iteration
[Learn python from scratch] 59. Iterator: an efficient tool for optimizing data traversal
[Learn python from scratch] 58. Custom exceptions in Python and methods of raising exceptions
[Learn python from scratch] 57. Use the with keyword in Python to correctly close resources
[Learn python from scratch] 56. The importance and application of exception handling in programming
[Learn python from scratch] 55. Serialization and deserialization in Python, application of JSON and pickle modules
[Learn python from scratch] 54. Write data in memory
[Learn python from scratch] 53. CSV files and Python’s CSV module
[Learn python from scratch] 52. Reading and writing files – Python file operation guide
[Learn python from scratch] 51. Opening and closing files and their application in Python
[Learn python from scratch] 49. Object-related built-in functions in Python and their usage
[Learn python from scratch] 48. Detailed explanation of inheritance and multiple inheritance in Python
[Learn python from scratch] 47. The concept and basic use of inheritance in object-oriented programming
[Learn python from scratch] 46. Analysis of __new__ and __init__ methods and singleton design pattern in Python
[Learn python from scratch] 45. Class methods and static methods in Python
[Learn python from scratch] 44. Private properties and methods in object-oriented programming
[Learn python from scratch] 43. Instance attributes and class attributes in Python object-oriented programming
[Learn python from scratch] 42. Built-in properties and methods in Python
[Learn python from scratch] 41. python magic method (2)
[Learn python from scratch] 40. python magic method (1)
[Learn python from scratch] 39. Basic object-oriented syntax and application examples
[Learn python from scratch] 38. How to use and import Python packages
[Learn python from scratch] 37. The use and precautions of Python custom modules
[Learn python from scratch] 36. Methods and techniques for using pip for third-party package management in Python
[Learn python from scratch] 35. Python common system modules and their usage
[Learn python from scratch] 34. Detailed explanation of how to import and use Python modules
[Learn python from scratch] 33. The role of decorators (2)
[Learn python from scratch] 32. The role of decorators (1)
[Learn python from scratch] 31. In-depth understanding of higher-order functions and closures in Python
[Learn python from scratch] 30. In-depth understanding of recursive functions and anonymous functions
[Learn python from scratch] 29. “Detailed explanation of function parameters” – Understand the different uses of Python function parameters
[Learn python from scratch] 28. Local variables and global variables in Python
[Learn python from scratch] 27. Use of Python functions and nested calls
[Learn python from scratch] 25. Function: a powerful tool to improve the efficiency of code writing
[Learn python from scratch] 24. String operations and traversal methods in Python
[Learn python from scratch] 23. How to use sets (set) and common operations in Python
[Learning python from scratch] 22. Addition, deletion, modification, and dictionary variables in Python
[Learn python from scratch] 21. Tuples and dictionaries in Python
[Learn python from scratch] 20. Python list operation skills and examples
[Learn python from scratch] 19. Application of looping through lists and list nesting
[Learn python from scratch] 18. Detailed explanation of the basic operations of Python lists (1)
[Learn python from scratch] 17. Python string format method (2)
[Learn python from scratch] 16. Python string format method (1)
[Learn python from scratch] 15. In-depth understanding of string and character set encoding
[Learn python from scratch] 14. Common operations on Python strings (2)
[Learn python from scratch] 13. Common operations on Python strings (1)
[Learn python from scratch] 12. Python string operations and applications
[Learn python from scratch] 11. Python loop statements and control flow
[Learn python from scratch] 10. Detailed explanation of Python conditional statements and if nesting
[Learn python from scratch] 09. Conditional judgment statements in Python
[Learn python from scratch] 08. Python understands bitwise operators and operator precedence
[Learn python from scratch] 07. Detailed explanation of Python operators: assignment, comparison and logical operators
[Learn python from scratch] 06. Use arithmetic operators for calculation and string concatenation in Python
[Learn python from scratch] 05. Output and input in Python
[Learn python from scratch] 04. Python programming basics: variables, data types and identifiers
[Learn python from scratch] 03. Python interactive programming and detailed explanation of comments
[Learn python from scratch] 02. Introduction to development tools
[Learn python from scratch] 01. Install and configure python