Donation- Aukos
[EN] For dictionaries and Lithuanian history topics.
[LT] Žodynų ir istorijos skilties vystymui

Amount: 

Login form



LINUX. Procesai, servisai, paslaugos: ps, kill, killall, jobs, top, htop, nice, renice komandos

PROCESSES
ctrl+c
ctrl+d
ctrl+z

Vykdome kodą:

sleep 1000
ctrl+z
sleep 1000
ctrl+z
sleep 1000
ctrl+z

Procesų lentelė (linux stilius)e- visi procesai, f išplėsta lentelė, F dar labiau išplėsta:
ps -ef | more

Procesų lentelė (BSD stilius)a- visi procesai turinys terminlą, x- ir neturintys, u- išplėsta lentelė:
ps aux | more

Vartotojo procesai:
ps -u jonas

Procesų medis:
pstree
pstree -p
pstree -cpa

ps lentelė:

UID
PID
PPID
C- processor utilization. Currently, this is the integer value of the percent usage over the lifetime of the process.
STIME- kiek laiko paleistas procesas.
TTY
TIME- bendras proceso laikas, į kurį įtraukiama ir  žlugusių procesų vaikų laikas (cumulative time).
CTIME- cumulative time
CMD
%CPU- cpu utilization of the process in "##.#" format. Currently, it is the CPU time used divided by the time the process has been running (cputime/realtime ratio), expressed as a percentage. It will not add up to 100% unless you are lucky.
%MEM- ratio of the process's resident set size to the physical memory on the machine, expressed as a percentage.
SHR- paskirstytųjų baitų atmintis.
VSZ- virtualios atminties dydis.
RSS- resident set size, the non-swapped physical memory that a task has used (in kiloBytes).
STAT- būsena runninig(naudoja procesoriaus laiką), sleeping(nenaudoja procesoriaus laiko), N(žemas prioritetas), <(aukštas prioritetas), T(traced or stopped- sustabdyti), R+(foregraund), S+(foreground, miegantis), L(locked, operat. atmintyje), W(neturi rez puslapių), Z(zombis),
SZ- approximate amount of swap space that would be required if the process were to dirty all writable pages and then be swapped out. This number is very rough!
PSR- processor that process is currently assigned to.

Vartotojo sustabdyti ir foniniai procesai:

jobs

Procesų numeriai:
jobs -p

http://www.die.net/doc/linux/man/man1/jobs.1.html

The character '+' identifies the job that would be used as a default for the fg or bg utilities; this job can also be specified using the job_id %+ or "%%" . The character '-' identifies the job that would become the default if the current default job were to exit; this job can also be specified using the job_id %-. For other jobs, this field is a <space>. At most one job can be identified with '+' and at most one job can be identified with '-' .

Veikiantys foniniai vartotojo procesai:

jobs -r

fg  %1
bg %1

kill %1
kill -l

Signal name Signal number Meaning:

SIGTERM 15 Terminate the process in an orderly way.
SIGINT 2 Interrupt the process. A process can ignore this
signal.
SIGKILL 9 Interrupt the process. A process can not ignore
this signal.
SIGHUP 1 For daemons: reread the configuration file.
You can read more about default actions that are taken when sending a signal to a process in man

kill -9 %1
kill -9 PID
kill -19 PID
killall sleep
killall -9 sleep

 


kill `pidof <programos_pavadinimas>`


PRIORITETAI, KONKURENCIJA

Kiek laiko vykdė komandą (iškvietimo-užbaigimo laikas, CPU laikas, kurį procesas praleido paleidusio procesą vartotojo režime, CPU laikas, kurį procesas praleido branduolio režime):

time sleep 10- vykdymolaikai

top

http://www.die.net/doc/linux/man/man1/top.1.html

PID -- Process Id
The task's unique process ID, which periodically wraps, though never restarting at zero.
PPID -- Parent Process Pid
The process ID of a task's parent.
UID -- User Id
The effective user ID of the task's owner.
USER -- User Name
The effective user name of the task's owner.
GROUP -- Group Name
The effective group name of the task's owner.
TTY -- Controlling Tty
The name of the controlling terminal. This is usually the device (serial port, pty, etc.) from which the process was started, and which it uses for input or output. However, a task need not be associated with a terminal, in which case you'll see '?' displayed.
PR -- Priority  (aktyvinimo lygis)
The priority of the task.
NI -- Nice value
The nice value of the task. A negative nice value means higher priority, whereas a positive nice value means lower priority. Zero in this field simply means priority will not be adjusted in determining a task's dispatchability.
extra demand for cpu time).
%CPU -- CPU usage
The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time. In a true SMP environment, if 'Irix mode' is Off, top will operate in 'Solaris mode' where a task's cpu usage will be divided by the total number of CPUs. You toggle 'Irix/Solaris' modes with the 'I' interactive command.
TIME -- CPU Time
Total CPU time the task has used since it started. When 'Cumulative mode' is On, each process is listed with the cpu time that it and its dead children has used. You toggle 'Cumulative mode' with 'S', which is a command-line option and an interactive command. See the 'S' interactive command for additional information regarding this mode.
TIME+ -- CPU Time, hundredths
The same as 'TIME', but reflecting more granularity through hundredths of a second.
%MEM -- Memory usage (RES)
A task's currently used share of available physical memory.
VIRT -- Virtual Image (kb)
The total amount of virtual memory used by the task. It includes all code, data and shared libraries plus pages that have been swapped out. (Note: you can define the STATSIZE=1 environment variable and the VIRT will be calculated from the /proc/#/state VmSize field.)
VIRT = SWAP + RES.
SWAP -- Swapped size (kb)
The swapped out portion of a task's total virtual memory image.
RES -- Resident size (kb)
The non-swapped physical memory a task has used.
RES = CODE + DATA.
CODE -- Code size (kb)
The amount of physical memory devoted to executable code, also known as the 'text resident set' size or TRS.
DATA -- Data+Stack size (kb)
The amount of physical memory devoted to other than executable code, also known as the 'data resident set' size or DRS.
SHR -- Shared Mem size (kb)
The amount of shared memory used by a task. It simply reflects memory that could be potentially shared with other processes.
S -- Process Status
The status of the task which can be one of: 'D' = uninterruptible sleep 'R' = running 'S' = sleeping 'T' = traced or stopped 'Z' = zombie


Tasks shown as running should be more properly thought of as 'ready to run' -- their task_struct is simply represented on the Linux run-queue. Even without a true SMP machine, you may see numerous tasks in this state depending on top's delay interval and nice value.

Parametrai:
buff- buferizacijai skirta atmintis.
cached- disko dydis, naudojamas buferizacijai (neįeina IN/OUT buferiai).

Pauzės nustatymas:
top d 1

Rikiavimas ir išrinkimas:

spaudžiam u ir rašom vartotojo vardą,
spaudžiam shift >, rikiuojam,
shift <,
shift R- reverse/normal rikiavimas,
F- rikiuojamo lauko pasirinkimas.

-20 (most favorable scheduling) to 19 (least favorable).

nice  -n 0 sh a1.txt &
nice  -n 0 sh a2.txt &
nice  -n 0 sh a3.txt &

top

renice -20 -p pirmas_procesas
renice  19 -p  antras_procesas

ax.txt:

file= ` echo $0.txt `
while (true); do
ls -l > $file
rm -rf $file

done

top, uptime komandoms

http://en.wikipedia.org/wiki/Load_(computing)

Load calculation under Unix(-like) systems

An idle computer has a load number of 0. Each process that is using CPU or waiting for CPU adds to the load number by 1. Some systems may also include threads in uninterruptible sleep states (usually waiting for disk activity).
The load average is calculated as the exponentially damped moving average of the load number. The three values of load average refer to the past one, five, and fifteen minutes of system operation.
For single CPU systems that are CPU-bound, one can think of load average as a percentage of system utilization during the respective time period. For systems with multiple CPUs, the number needs to be divided by the number of CPUs in order to get a percentage.
For example a load average of "3.73 7.98 0.50" on a single CPU system can be interpreted as:

  • the CPU was overloaded by 373% (needed to do 373% as much work as it can do in a minute) during the last minute.
  • it was only busy half of the time for the last fifteen minutes

Rather, this means that this CPU could have handled all of the work scheduled for the last minute if it were 3.73 times as fast (or if there were 3.73 times as many more CPUs), but over the last fifteen minutes it was twice as fast as it needed to be to keep up.
Conversely, in a system with four CPUs, a load average of 3.73 would indicate that there were on average 3.73 processes running or queued, that is, that the system is not lacking in this respect because 3.73 is still lower than 4.
On modern UNIX systems, the treatment of threading with respect to load averages varies. Some systems treat threads as processes for the purposes of load average calculation: each thread waiting to run will add 1 to the load. However, other systems, especially systems implementing M:N threading, use different strategies, such as counting the process exactly once for the purpose of load (regardless of the number of threads), or counting only threads currently exposed by the user thread scheduler to the kernel, which may depend on the level of concurrency set on the process.

 

Sygnals

Signal     Value     Action   Comment
SIGHUP        1       Term    Hangup detected on controlling terminal
or death of controlling process
SIGINT        2       Term    Interrupt from keyboard
SIGQUIT       3       Core    Quit from keyboard

Hangup detected on controlling terminal usually means that someone has
logged out.  If you start a background process and log out, the background
process will terminate.  Thats why the nohup command was invented many
years go ago.

If you run "stty -a" you'll see what keys maps to different keyboard events.
I have intr=^C and quit=^\ where ^ = control.

If I have a running process and type Ctrl-C, it will get SIGINT which
normally causes it to terminate.  If I type Ctrl-\, it will generate a
core file and exit.

Applications can override most default signal handlers (SIGTERM cannot)
via fun functions like sigaction().

 

 
[ BBC news ][ Yahoo news ][ Linux guru ][ Webmaster ACE ]