0Pricing
Linux Command Line Mastery · Lezione

Priorità dei processi con nice, renice e i segnali

Controlli la quantità di CPU assegnata ai processi usando nice e renice e impari come i segnali consentano di comunicare con i processi in esecuzione, non solo di terminarli.

Priorità dei processi con nice, renice e i segnali è una lezione Linux Command Line Mastery gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Linux Command Line Mastery, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Linux Command Line Mastery include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

Beyond Starting and Stopping

You already know how to view processes with ps/top and stop them with kill. But sometimes a process should simply run more politely so it does not starve others of CPU.

That is what nice and renice are for.

What Is a Niceness Value?

Every process has a niceness from -20 (highest priority) to 19 (lowest priority). A nicer process yields CPU to others. Default is 0.

Starting a Process with nice

nice -n N command launches a command with niceness N. Higher numbers are friendlier to the rest of the system.

nice -n 10 tar -czf backup.tar.gz /var/log

Viewing Niceness

The NI column in top shows niceness. With ps you can request it explicitly.

ps -o pid,ni,comm -p 1

Changing Priority with renice

renice adjusts the niceness of an already running process by PID.

renice -n 5 -p 1234

Why You Need Root to Raise Priority

Any user can make a process nicer (raise the number). Only root can give a process a negative niceness, because that takes CPU away from everyone else.

sudo renice -n -5 -p 1234

Signals: More Than kill

The kill command really sends a signal. SIGTERM (15) asks nicely to stop; SIGKILL (9) forces it; SIGHUP (1) often tells a daemon to reload config.

kill -l

Reloading Without Restarting

Sending SIGHUP to many services makes them re-read their configuration without a full restart, avoiding downtime.

kill -HUP 4567

Pausing and Resuming a Process

SIGSTOP freezes a process and SIGCONT resumes it, handy for temporarily relieving load.

kill -STOP 4567
kill -CONT 4567

Targeting by Name

pkill and killall let you send signals by process name instead of PID.

pkill -HUP nginx

Putting It Together

A typical admin flow: spot a CPU hog in top, lower its priority with renice instead of killing it, and only escalate to kill -9 if it misbehaves.

renice -n 15 -p 8899 || kill -TERM 8899

Quick Check

Which niceness value gives a process the highest CPU priority?

Recap

You learned to fine-tune process behavior:

  • nice -n N cmd starts at a chosen priority
  • renice changes priority of running PIDs
  • Negative niceness needs root
  • Signals like SIGTERM, SIGHUP, SIGSTOP/SIGCONT control processes without killing them

Domande Frequenti

La lezione «Priorità dei processi con nice, renice e i segnali» è gratuita?

Sì — il testo completo di «Priorità dei processi con nice, renice e i segnali» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Linux Command Line Mastery, passa a CoddyKit PRO. Il corso Linux Command Line Mastery include 4 lezioni in totale.

Cosa imparerò in «Priorità dei processi con nice, renice e i segnali»?

Controlli la quantità di CPU assegnata ai processi usando nice e renice e impari come i segnali consentano di comunicare con i processi in esecuzione, non solo di terminarli. Eserciti Linux Command Line Mastery con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare Linux Command Line Mastery?

Non è richiesta alcuna esperienza precedente. Linux Command Line Mastery su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.

Quanto tempo richiede la lezione «Priorità dei processi con nice, renice e i segnali»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione Linux Command Line Mastery?

Sì. Ogni lezione Linux Command Line Mastery include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Comprendere i processi: `ps`, `top`, `htop`
  2. Gestione dei processi: `kill`, `bg`, `fg`
  3. Monitoraggio delle risorse di sistema: `df`, `du`, `free`
  4. Priorità dei processi con nice, renice e i segnali
← Torna a Linux Command Line Mastery