eolas/Programming_Languages/Shell_Scripting/Processes.md
2022-05-26 08:30:05 +01:00

1.4 KiB

tags
Programming_Languages
shell
processes

Processes (ps)

ps allows us to control user processes from the shell.

The command in its most minimal application returns the following

  PID TTY       TIME     CMD
  2437 pts/2    00:00:01 zsh
  7112 pts/2    00:00:00 ps
pid
Process ID: every currently running process has a unique ID
tty
The terminal device where the process is running
Time
The amount of CPU time in minutes and seconds that the process has used so far. The total amount of time that the process has spent running instructions on the processor.
cmd
The command used to run the program. Note this can change during the running of the program.

Modifiers

ps x
Show all running processes
ps ax
Show all processes not just the ones you, the current user, own
ps u
Show detailed info on processes
ps w
Show full command names

Process termination

The general schema is: kill [pid]. This allows for process clean-up. If this doesn't succeed you can force with KILL [pid] which will terminate the process immediately but is obviously more risky.

We can also start/stop processes with modifiers on kill:

  • kill -STOP pid
  • kill -CONT pid