skill

Send a signal to the selected process to freeze the process

Supplementary instructions

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: activation mode;
-V: Display version number;
-t: Specify the terminal number to start the process;
-u: Specify the user who starts the process;
-p: Specifies the ID number of the process;
-c: Specifies 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 parameters. 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, usually run by user "oracle". Therefore, when you wish to stop a process named "oracle", you 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 function of snice command is similar 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.