Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung Nächste Überarbeitung | Vorherige Überarbeitung Nächste Überarbeitung Beide Seiten, nächste Überarbeitung | ||
admin_grundlagen:prozesse [2012/10/07 15:18] ingo_wichmann |
admin_grundlagen:prozesse [2019/12/21 07:47] ingo_wichmann |
||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== Jobverwaltung der bash ====== | ||
- | Vordergrundprozess anhalten: | ||
- | ''STRG+z'' | ||
- | |||
- | Job in den Hintergrund schieben: | ||
- | bg | ||
- | Job in den Vordergrund schieben: | ||
- | fg | ||
- | Jobs anzeigen: | ||
- | jobs | ||
- | |||
- | Programm im Hintergrund laufen lassen: | ||
- | sleep 10 & | ||
- | |||
====== Prozessverwaltung ====== | ====== Prozessverwaltung ====== | ||
- | |||
===== Prozesse anzeigen ===== | ===== Prozesse anzeigen ===== | ||
==== ps ==== | ==== ps ==== | ||
Zeile 22: | Zeile 7: | ||
)) | )) | ||
ps -e | ps -e | ||
+ | |||
+ | Anzeigen aller Prozesse und Threads: | ||
+ | ps -T -e | ||
+ | |||
+ | Anzeigen aller Kernel-Threads: | ||
+ | ps -f -p 2 --ppid 2 | ||
+ | |||
+ | Kernel-Threads die mit /nummer angezeigt werden laufen auf der CPU mit der entsprechenden Nummer. | ||
+ | (( | ||
+ | Beispiele für Kernel-Threads (die Liste ist weder aktuell noch vollständig): | ||
+ | * migration: Used to move processes between CPUs - for load balancing | ||
+ | * ksoftirqd: Kernel healper thread to handle softirqs that can't be handled immediately | ||
+ | * watchdog: Notices if the system appears to be hung | ||
+ | * events: Handles kernel workqueues that aren't handled by other threads | ||
+ | * khelper: used as a schedulable context for stuff that call_user_mode_helper wants to run; like /sbin/hotplug or modprobe | ||
+ | * kblockd: used for running low-level disk operations | ||
+ | * kacpid: deals with ACPI - such as for power saving functions | ||
+ | * khubd: used for configuring USB | ||
+ | * kseriod: used for handling serial io | ||
+ | * khungtaskd: used for detecting hung tasks | ||
+ | * pdflush: sends memory to disk - to free RAM | ||
+ | * kswapd: swaps processes to disk | ||
+ | * aio: handles asynchronous IO | ||
+ | * kpsmoused: handles mouse IO | ||
+ | * scsi_eh: SCSI event handler | ||
+ | * qla2xxx_0_dpc: qla device driver thread | ||
+ | * scsi_wq: scsi work queue handler | ||
+ | * fc_wq: fiber chanel work queue handler | ||
+ | * fc_dl: fiber chanel handler | ||
+ | * kstriped: helper thread for striped volumes | ||
+ | * ksnapd: helper thread for handling dm-snaps (disk snapshots) | ||
+ | * kjournald: helper thread for handling filesystem journals | ||
+ | * kauditd: kernel thread for handling audit events | ||
+ | * kmpathd: multipath daemon helper thread | ||
+ | * ib_*: infiniband threads | ||
+ | * kworker: handles delayed work from throughout the kernel where the work is not being handled by one of the other queues. The number of kworker threads vary over time based on the amount of work in the work queues. | ||
+ | * kondemand: Used by ondemand CPU frequency govenor | ||
+ | )) | ||
+ | |||
+ | === Status === | ||
+ | {{:admin_grundlagen:process_status.png?direct&200|}} (( aus ''man waitpid'': //A child that terminates, but has not been waited for becomes a "zombie". The kernel maintains a minimal set of information about the zombie process (PID, termination status, resource usage information) in order to allow the parent to later perform a wait to obtain information about the child. As long as a zombie is not removed from the system via a wait, it will consume a slot in the kernel process table, and if this table fills, it will not be possible to create further processes. If a parent process terminates, then its "zombie" children (if any) are adopted by init(1), (or by the nearest "subreaper" process ...; init(1) automatically performs a wait to remove the zombies.//)) | ||
+ | |||
Anzeigen aller Prozesse, incl. Benutzer: | Anzeigen aller Prozesse, incl. Benutzer: | ||
(( | (( | ||
Zeile 33: | Zeile 60: | ||
Anzeige ausgewählter Prozesse und ausgewählter Felder sortiert: | Anzeige ausgewählter Prozesse und ausgewählter Felder sortiert: | ||
ps -C gzip,bzip2 -o cmd,uname,rsz,cputime,%cpu,state --sort rsz | ps -C gzip,bzip2 -o cmd,uname,rsz,cputime,%cpu,state --sort rsz | ||
- | | + | |
+ | Mit dem BSD Befehlssatz | ||
+ | Alle Prozess, mit User und MEM/CPU-Statistik, als Wide (volle Kommandozeile) und als Baum (f) | ||
+ | ps ax | ||
+ | ps aux | ||
+ | ps auxw | ||
+ | ps auxwf | ||
Anzeige aller Prozesse incl. cgroup: | Anzeige aller Prozesse incl. cgroup: | ||
Zeile 43: | Zeile 77: | ||
Anzeigen, welche Dateien ein Prozess geöffnet hat: | Anzeigen, welche Dateien ein Prozess geöffnet hat: | ||
lsof -p 4711 | lsof -p 4711 | ||
+ | oder | ||
+ | lsof -c update-notifier | ||
Prozesse baumartig darstellen: | Prozesse baumartig darstellen: | ||
pstree | pstree | ||
+ | pstree -p | ||
+ | pstree -up | ||
+ | Prozessbaum der eigenen Shell (long) | ||
+ | pstree -pul -s $$ | ||
Prozesse nach Ressourcenverbrauch sortiert anzeigen: | Prozesse nach Ressourcenverbrauch sortiert anzeigen: | ||
top | top | ||
+ | Modernere Variante von top: | ||
+ | htop | ||
===== Prozess Prioritäten ===== | ===== Prozess Prioritäten ===== | ||
Zeile 54: | Zeile 96: | ||
ps -p $$ -o pid,nice,cmd | ps -p $$ -o pid,nice,cmd | ||
- | Prozess mit um 5 erhöhter Priorität starten: | + | Prozess mit um 5 abgesenkter Priorität starten: |
nice -5 bash | nice -5 bash | ||
Zeile 115: | Zeile 157: | ||
- Die gesamte Menge an Swapspace, die zur Verfügung steht. | - Die gesamte Menge an Swapspace, die zur Verfügung steht. | ||
- Der belegte Swapspace | - Der belegte Swapspace | ||
- | - Der noch freie Swapspace, also (9) abzüglich (10) | + | - Der noch freie [[Swap|Swapspace]], also (9) abzüglich (10) |
Das bedeutet also, dass im Falle ganz oben insgesamt 167M von | Das bedeutet also, dass im Falle ganz oben insgesamt 167M von | ||
Zeile 147: | Zeile 189: | ||
dd bs=1M count=1500 < /dev/zero | sort > /dev/null | dd bs=1M count=1500 < /dev/zero | sort > /dev/null | ||
+ | Oder einfach: | ||
+ | echo 3 > /proc/sys/vm/drop_caches | ||
===== Beispiel: Speicher füllen ===== | ===== Beispiel: Speicher füllen ===== | ||
Prozess starten, der 2000MB verbraucht: | Prozess starten, der 2000MB verbraucht: | ||
dd if=/dev/zero bs=1M count=2000 | perl -e '$slurp=<>; sleep' | dd if=/dev/zero bs=1M count=2000 | perl -e '$slurp=<>; sleep' | ||
+ | oder | ||
+ | dd if=/dev/zero bs=1M count=2000 | read slurp | ||
+ | |||
- | ====== Links ====== | ||
- | * http://blog.koehntopp.de/archives/2633-Wieviel-Speicher-brauchst-Du-denn.html |