• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
101 3.5 create, monitor and kill processes
 

101 3.5 create, monitor and kill processes

on

  • 178 views

 

Statistics

Views

Total Views
178
Views on SlideShare
178
Embed Views
0

Actions

Likes
1
Downloads
6
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    101 3.5 create, monitor and kill processes 101 3.5 create, monitor and kill processes Presentation Transcript

    • Junior Level Linux Certification
    • Exam Objectives Key Knowledge Areas Run jobs in the foreground and background. Signal a program to continue running after logout. Monitor active processes. Select and sort processes for display. Send signals to processes. Objective 3: GNU and Unix Commands Create, monitor and kill processes Weight: 4 Terms and Utilities & bg fg jobs kill nohup ps top free uptime killall 2
    • Create, monitor and kill processes Job control - Ability to selectively suspend execution of processes and continue their execution later. A job is a process or a pipeline of processes that were started by the shell. Job control 3 job which receives keyboard input is called the foreground job. •When a foreground process is running, it receives keyboard input and signals. •Processes started are run in foreground by default and continue until they exit. To run a process in background – input command followed by special character & •Processes running in the background may still send output to the terminal. •They do not receive keyboard input unless they are brought to the foreground. When bash starts a background job, it prints a line with: - job number and - process ID of last process in pipeline
    • Create, monitor and kill processes Job control - Ability to selectively suspend execution of processes and continue their execution later. A job is a process or a pipeline of processes that were started by the shell. Job control 4 job which receives keyboard input is called the foreground job. •When a foreground process is running, it receives keyboard input and signals. •Processes started are run in foreground by default and continue until they exit. To run a process in background – input command followed by special character & •Processes running in the background may still send output to the terminal. •They do not receive keyboard input unless they are brought to the foreground. When bash starts a background job, it prints a line with: - job number and - process ID of last process in pipeline
    • Create, monitor and kill processes command jobs displays current list of jobs either running or stopped. jobs 5 foo:~ $ dd if=/dev/zero of=/dev/null bs=1 & [1] 1181 foo:~ $ cat /dev/urandom | grep hello & [2] 1183 foo:~ $ jobs [1]- Running dd if=/dev/zero of=/dev/null bs=1 & [2]+ Running cat /dev/urandom | grep hello & Ex:
    • Create, monitor and kill processes Control jobs 6 key sequences entered to foreground processes: Key Signal Meaning Usage Ctrl+C SIGINT Interrupt Interrupt the program running in the foreground Ctrl+Z SIGSTOP Suspend Suspend the program running in the foreground cmds entered to control background processes. Command Meaning Usage fg foreground Run the background job in the foreground. If it has suspended, restart it. bg background Restart a suspended job. fg makes most recently executed job a foreground job. You can specify a specific job number. (Ex. fg 2 will make job 2 run in the foreground) bg makes most recently executed job continue to run in background. You can make a specific job run in the background by specifying a job number (Ex. bg 2)
    • Create, monitor and kill processes Control jobs 7 kill command kill job based on job number (instead of PID) using percentage sign to specify the job number foo:~ $ jobs [1]- Running dd if=/dev/zero of=/dev/null bs=1 & [2]+ Running cat /dev/urandom | grep hello & foo:~ $ kill %1 foo:~ $ [1]- Terminated dd if=/dev/zero of=/dev/null bs=1 foo:~ $ jobs [2]+ Running cat /dev/urandom | grep hello & foo:~ $ kill %2 foo:~ $ [2]+ Terminated cat /dev/urandom | grep hello Ex:
    • Create, monitor and kill processes Disconnected processes 8 commands nohup and setsid - used to run processes disconnected from terminal that started them. nohup sets the signal mask for the process it starts to ignore the SIGHUP signal. SIGHUP signal is sent to each process when the shell exits. - happens when you exit a session on console, or via network connection. •nohup writes the output to a file - nohup.out •nohup is generally used - When you know that the process you are going to run should continue to run after your session ends.
    • Create, monitor and kill processes Monitoring processes 9 ps – process status options supported by ps are somewhat complex. GNU version supports: Unix98 options (letters); BSD options (dash); GNU options (two dashes). To ... Unix98 BSD - Show all processes ps -ax ps -A ps -e - Show full info ps -u (user format) ps -f (full listing) - Show full info for all processes ps -uax ps -ef ps -Af foo:~ $ ps -f UID PID PPID C STIME TTY TIME CMD georgem 987 612 0 20:32 pts/2 00:00:00 /bin/bash georgem 3398 987 0 21:11 pts/2 00:00:00 ps -f foo:~ $ ps u USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND georgem 987 0.0 1.7 4676 2040 pts/2 S 20:32 0:00 /bin/bash georgem 3399 0.0 0.5 2524 696 pts/2 R 21:11 0:00 ps u Ex: ps -w – display in wide format ps -f – display in forest of processes, similar to output of pstree.
    • Create, monitor and kill processes Monitoring processes 10 top – displays processes that use up the most CPU or memory. Ex:
    • Create, monitor and kill processes Signals 11 Processes in Linux do not communicate with each other directly, but send each other signals via kernel. most common signal sent is SIGTERM, means Terminate, unless you know what to do signal(7) man page. Ex: http://linux.about.com/od/commands/l/blcmdl7_signal.htm
    • Fim de sessão 12