# Certification Linux LPI/Administrateur système débutant/Examen 101/GNU et commandes Unix/Créer, surveiller et terminer des processus

Il a été demandé de traduire cette page depuis

## Objectifs

Description: Les candidats devraient pouvoir gérer les processus.
Cela comprend:
* La compréhension de la façon d'exécuter un job en tache de fond ou non (foreground and background);
* De modifier leur statut (background vers foreground et vice versa);
* Démarrer un processus qui s'exécutera sans connexion à un terminal et signaler au programme de continuer après le logout.
Les taches comprennent aussi la gestion des processus actifs:
* En sélectionnant et triant les processus pour visualisation;
* En envoyant des signaux au processus;
* En tuant des processus;
* En identifiant et tuant des applications X qui ne se sont pas arretées alors que la session X est close.
Key files terms and utilities include: & bg fg jobs kill nohup ps top

## Créer des processus

A running application is a process. Every processes have: A process ID. A parent process ID. A current directory PWD. A file descriptor table. A program which it is executing. Environment variables, inherited from its parent process. Stdin, stdout, and stderr Other
Bash is a program that when it is executed becomes a process. Each time you execute a command in a shell a new process is created. Except for the built-in shell command. They run in the shell context. Use type to check if a command is a built-in shell command.
Example type cp ls which type Monitor processes Once the system is up and running from a terminal it is possible to see which processes are running with the ps program. To display a long format of all the processes in the system, do:
The ps program will display all the processes running and their PID numbers and other information. To see a long format of the processes in your login session, do a:

## Surveiller des processus

To monitor the processes in real-time, use top. top
78 processes: 75 sleeping, 3 running, 0 zombie, 0 stopped CPU states: 15.3% user, 0.3% system, 0.0% nice, 84.2% idle Mem: 254896K av, 251204K used, 3692K free, 0K shrd, 27384K buff Swap: 514072K av, 0K used, 514072K free 120488K cached
RSS: The total amount of physical memory used by the task. SHARE: The amount of shared memory used by the task. %CPU: The task's share of the CPU time. %MEM: The task's share of the physical memory. Once top is running it is also possible to execute interactive commands: Type N to sort tasks by pid. Type A to sort tasks by age (newest first). Type P to sort tasks by CPU usage. Type M to sort tasks by memory usage. Type k to kill a process (prompted for pid).

## Terminer des processus

The ps program will display all the processes running and their PID numbers. Once the PID is known, it is possible to send signals to the process. SIGSTOP to stop a process. SIGCONT to continue a stopped process. SIGKILL to kill a process.
The program to send a signal to a process is called kill.
By default a process is started in foreground and it is the only one to receive keyboard input. Use CTRL+Z to suspend it.
To start a process in backgroud use the &.
Job control
In a bash process it is possible to start multiple jobs. The command to manipulate jobs are:
When bash is terminated all processes that have been started from the session will receive the SIGHUP signal. This will by default terminate the process.
To prevent the termination of a process, the program can be started with the nohup command.

## Solution des exercices

1. La ligne à ajouter dans /etc/fstab est
/dev/fd0 /media/floppy auto rw,user,noauto 0 0
| Utiliser les flux, les tuyeaux (pipes) et les re-directions | Modifier les priorités d'exécution des processus |