Linux Server Configuration


Sending Signals to Daemons: pidof


Download 493.5 Kb.
bet10/48
Sana16.06.2023
Hajmi493.5 Kb.
#1495871
1   ...   6   7   8   9   10   11   12   13   ...   48
Bog'liq
0501-linux-server-configuration

1.5.6 Sending Signals to Daemons: pidof


On UNIX systems, long-lived processes that provide some service are often referred to as


daemons. Daemons typically have a configuration file (usually under /etc) which affects their behavior. Many daemons read their configuration file only at startup. If the configuration changes, you have to explicitly tell the daemon by sending it a SIGHUP signal. We can sometimes use pidof to find the dæmon’s pid: for example, to tell the inetd dæmon to reload its configuration, we can run:

$ kill -HUP $(pidof /usr/sbin/inetd)




1.5.7 Process Priorities: nice


Not all tasks require the same amount of execution time. Linux has the concept of execution priority to deal with this. Process priority is dynamically altered by the kernel. We can view the current priority by looking at top or ps -l and looking at the PRI column. The priority can be biased using nice. The current bias can be seen in the NI column in top.


The nice command starts a program with a given priority bias. Peculiar name: ‘nicer’ processes require fewer resources. Niceness ranges from +19 (very nice) to −20 (not very nice). Non-root users can only specify values from 1 to 19; the root user can specify the full range of values. Default niceness when using nice is 10.


To run a command at increased niceness (lower priority):


$ nice -10 long-running-command &


$ nice -n 10 long-running-command &

To run a command at decreased niceness (higher priority):


$ nice --15 important-command &


$ nice -n -15 important-command &


1.5.8 Modifying Priorities: renice


The command renice changes the niceness of existing processes. Non-root users are only permitted to increase a process’s niceness. To set the process with pid 2984 to a higher niceness (lower priority):


$ renice 15 2984


The niceness is just a number: no extra – sign. To set the process with pid 3598 to a lower niceness (higher priority):


$ renice -15 3598

You can also change the niceness of all a user’s processes:


$ renice 15 -u mikeb



Download 493.5 Kb.

Do'stlaringiz bilan baham:
1   ...   6   7   8   9   10   11   12   13   ...   48




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling