SlideShare uma empresa Scribd logo
1 de 26
Baixar para ler offline
RedHat Enterprise Linux Essential
  Unit 10: Investigating and Managing
               Processes
Investigating and Managing Processes
Upon completion of this unit, you should be able to:

 Explain what a process is

 Describe how to manage processes

 Use job control tools
What is a Process?

 A process is a set of instructions loaded into memory

   Numeric Process ID (PID) used for identification

   UID, GID and SELinux context determines filesystem access

     • Normally inherited from the executing user
Listing Processes

 View Process information with ps
    Shows processes from the current terminal by default

    a includes processes on all terminals

    x includes processes not attached to terminals

    u prints process owner information

    f prints process parentage

    o PROPERTY,... prints custom information:
       • pid, comm, %cpu, %mem, state, tty, euser, ruser

    Process states – running, sleeping, uninterruptable sleep, zombie.
Finding Processes


 Most flexible: ps options | other commands
      ps axo comm,tty | grep ttyS0

      ps -ef

 By predefined patterns: pgrep

               $ pgrep -U root

               $ pgrep -G student

●    By exact program name: pidof

               $ pidof bash
Example with cpu




ps –Ao pcpu,pid,user,args | sort –k 1 –r |head -10
Signals

 Most fundamental inter-process communication
    Sent directly to processes, no user-interface required

    Programs associate actions with each signal

    Signals are specified by name or number when sent:
       • Signal 15, TERM (default) - Terminate cleanly   (stopping)

       • Signal 9, KILL - Terminate immediately          (kill)

       • Signal 1, HUP - Re-read configuration files     (reload)

       • Kill –l         list info for singal

       • man 7 signal shows complete list
Sending Signals to Processes

 By PID: kill [signal] pid ...

 By Name: killall [signal] comm ...

 By pattern: pkill [-signal] pattern
Scheduling Priority

 Scheduling priority determines access to the CPU

 Priority is affected by a process‘ nice value

 Values range from -20 to 19 but default to 0
    Lower nice value means higher CPU priority

 Viewed with ps -Ao comm,nice
      ex: firefox &

      ps –Ao comm,nice |grep firefox
Altering Scheduling Priority

 Nice values may be altered...
    When starting a process:

       $ nice -n 5 command

    After starting:

       $ renice 5 PID

       renice 5 –p PID

 Only root may decrease nice values
Interactive Process Management Tools

 CLI: top

 GUI: gnome-system-monitor

 Capabilities
    Display real-time process information

    Allow sorting, killing and re-nicing
Job Control
 Run a process in the background

    Append an ampersand to the command line: firefox &

 Temporarily halt a running program
    Use Ctrl-z or send signal 17 (STOP)

 Manage background or suspended jobs
    List job numbers and names: jobs

    Resume in the background: bg [%jobnum]

    Resume in the foreground: fg [%jobnum]

    Send a signal: kill [-SIGNAL] [%jobnum]
Scheduling a Process To Execute Later

 One-time jobs use at, recurring jobs use crontab


    Create         at time               crontab -e
    List           at -l                 crontab -l
    Details        at -c jobnum          N/A
    Remove         at -d jobnum          crontab -r
    Edit           N/A                   crontab -e



 Non-redirected output is mailed to the user

 root              can modify jobs for other users
Using at
 Setting an at job: at [options] time
    Options:
     -b                run command only when the system load is low
     -d job#           delete an at job from queue
     -f filename       read job from a specified file
     -l                list jobs for that user (all jobs for root)
     -m                mail user quen job completes
     -q queuename      send the jobs to a queue (a to z and A to Z)
    Time formats:
      now, 17:00, +3 hours, +2 minutes, +2 days, +3 months, 19:15 3.12.10,
     midnight, 4PM, 16:00 +3 days, mon, tomorrow …
 Show the at jobs queue of user: atq or at –l
 Deletes at jobs from the jobs queue: atrm job# [job#] …
Examples with at
 Create an simple at job to run in 5 minutes later
   $ at now+5 minutes
   echo “I am running in an at job” > /tmp/test_cron
   [Ctrl-D]
 Create an at job which read commands from a file and run at
  midnight
   $ at –f /tmp/myjob.sh midnight
 Using echo to run multiple commands with at
  $ echo „cd /tmp; ls –a > /tmp/test_cron ‟ | at now+2 minutes
 Listing all at jobs
  $ at –l
  $ atq
crontab commands

 Create/edit a user crontab: crontab –e

 Create a user crontab by reading from file:
  crontab –e filename

 Display user‟s crontab file: crontab –l

 Delete user‟s crontab file: crontab –r

 Edit a user‟s crontab file (for root only):
  crontab –e –u username
Crontab File Format

 Entry consists of five space-delimited fields followed by a
  command line

  01 * * * * root        cd /tmp && ls -laht
    One entry per line, no limit to line length

 Fields are minute, hour, day of month, month, and day of week

 Comment lines begin with #

 See man 5 crontab for details
Examples of user crontabs
 Run a command every hour from 8:00 to 18:00 everyday
  0    8-18     *        *         *       <command>
 Run a command every 4 hours on the half hour (i.e 6:30, 10:30, 14:30, 16:30)
  everyday
  30 6-16/4 *            *         *       <command>
 Run a command every day, Monday to Friday at 01:00, and doesn‟t report to
  syslog
  -0 1          *        *         1-5     <command>
 Run the command every Monday and Tuesday at 12:00, 12:10, 12:20, 12:30
  0,10,20,30    12       *         *       1,2     <command>
 Run a command every 10 minutes
  */10 *        *        *         *       <command>
    echo “00 21 * * 7 root rm -f /tmp/*.log” >> /etc/crontab
    crontab -e
       00 8-17 * * 1-5 du -sh $HOME >> /tmp/diskreport
Grouping Commands


 Two ways to group commands:
   Compound: date; who | wc -l
     • Commands run back-to-back

   Subshell: (date; who | wc -l) >> /tmp/trace
     • All output is sent to a single STDOUT and STDERR
Exit Status

 Processes report success or failure with an exit status
    0 for success, 1-255 for failure

    $? stores the exit status of the most recent command
    exit [num] terminates and sets status to num

 Example:

       $ ping -c1 -W1 localhost999 &> /dev/null

       $ echo $?

       2
Conditional Execution Operators

 Commands can be run conditionally based on exit status
    && represents conditional AND THEN

    || represents conditional OR ELSE

 Examples:
      $ grep -q no_such_user /etc/passwd || echo 'No such user'

      No such user

      $ ping localhost &> /dev/null 

      >   && echo “localhost is up"      

      >   || echo ‘localhost is unreachable’
      localhost is up
The test Command

 Evaluates boolean statements for use in conditional execution
    Returns 0 for true

    Returns 1 for false

 Examples in long form:
       test "$A" = "$B" && echo "string" || echo "not equal"

       $ test "$A" -eq "$B" && echo "Integers are equal“

 Examples in shorthand notation:
       $ [ "$A" = "$B" ] && echo "Strings are equal"

       $ [ "$A" -eq "$B" ] && echo "Integers are equal"
File Tests

 File tests:
    -f tests to see if a file exists and is a regular file

    -d tests to see if a file exists and is a directory

    -x tests to see if a file exists and is executable

 [ -f ~/lib/functions ] && source ~/lib/functions
File Tests (cont’)

Options   Mean
-d file   True if the file is a directory.
-e file   True if the file exists.
-f file   True if the file exists and is a regular file.
-h file   True if the file is a symbolic link.
-L file   True if the file is a symbolic link.
-r file   True if the file exists and is readable by you.
-s file   True if the file exists and is not empty.
-w file   True if the file exists and is writable by you.
-x file   True if the file exists and is executable by you.
-O file   True if the file is effectively owned by you.
-G file   True if the file is effectively owned by your group.
Scripting: if Statements
 Execute instructions based on the exit status of a command
if ping -c1 -w2 station1 &> /dev/null; then

     echo 'Station1 is UP'

elif grep "station1" ~/maintenance.txt &> /dev/null; then

     echo 'Station1 is undergoing maintenance'

else

     echo 'Station1 is unexpectedly DOWN!'

     exit 1

fi
Unit 10 investigating and managing

Mais conteúdo relacionado

Mais procurados

Grafana optimization for Prometheus
Grafana optimization for PrometheusGrafana optimization for Prometheus
Grafana optimization for PrometheusMitsuhiro Tanda
 
Kubernetes design principles, patterns and ecosystem
Kubernetes design principles, patterns and ecosystemKubernetes design principles, patterns and ecosystem
Kubernetes design principles, patterns and ecosystemSreenivas Makam
 
Install and configure linux
Install and configure linuxInstall and configure linux
Install and configure linuxVicent Selfa
 
Shell Scripting in Linux
Shell Scripting in LinuxShell Scripting in Linux
Shell Scripting in LinuxAnu Chaudhry
 
Docker Compose | Docker Compose Tutorial | Docker Tutorial For Beginners | De...
Docker Compose | Docker Compose Tutorial | Docker Tutorial For Beginners | De...Docker Compose | Docker Compose Tutorial | Docker Tutorial For Beginners | De...
Docker Compose | Docker Compose Tutorial | Docker Tutorial For Beginners | De...Simplilearn
 
OpenShift Enterprise 3.1 vs kubernetes
OpenShift Enterprise 3.1 vs kubernetesOpenShift Enterprise 3.1 vs kubernetes
OpenShift Enterprise 3.1 vs kubernetesSamuel Terburg
 
Terraform vs Pulumi
Terraform vs PulumiTerraform vs Pulumi
Terraform vs PulumiHoaiNam307
 
Docker Swarm for Beginner
Docker Swarm for BeginnerDocker Swarm for Beginner
Docker Swarm for BeginnerShahzad Masud
 
Introduction to the Container Network Interface (CNI)
Introduction to the Container Network Interface (CNI)Introduction to the Container Network Interface (CNI)
Introduction to the Container Network Interface (CNI)Weaveworks
 
Understanding docker networking
Understanding docker networkingUnderstanding docker networking
Understanding docker networkingLorenzo Fontana
 
Using Rook to Manage Kubernetes Storage with Ceph
Using Rook to Manage Kubernetes Storage with CephUsing Rook to Manage Kubernetes Storage with Ceph
Using Rook to Manage Kubernetes Storage with CephCloudOps2005
 
Management file and directory in linux
Management file and directory in linuxManagement file and directory in linux
Management file and directory in linuxZkre Saleh
 
Docker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting TechniquesDocker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting TechniquesSreenivas Makam
 
Monitoring kubernetes with prometheus
Monitoring kubernetes with prometheusMonitoring kubernetes with prometheus
Monitoring kubernetes with prometheusBrice Fernandes
 
An Introduction To Jenkins
An Introduction To JenkinsAn Introduction To Jenkins
An Introduction To JenkinsKnoldus Inc.
 
Kubernetes API - deep dive into the kube-apiserver
Kubernetes API - deep dive into the kube-apiserverKubernetes API - deep dive into the kube-apiserver
Kubernetes API - deep dive into the kube-apiserverStefan Schimanski
 
Introduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageIntroduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageejlp12
 
Server configuration
Server configurationServer configuration
Server configurationAisha Talat
 

Mais procurados (20)

Grafana optimization for Prometheus
Grafana optimization for PrometheusGrafana optimization for Prometheus
Grafana optimization for Prometheus
 
Kubernetes design principles, patterns and ecosystem
Kubernetes design principles, patterns and ecosystemKubernetes design principles, patterns and ecosystem
Kubernetes design principles, patterns and ecosystem
 
Install and configure linux
Install and configure linuxInstall and configure linux
Install and configure linux
 
Shell Scripting in Linux
Shell Scripting in LinuxShell Scripting in Linux
Shell Scripting in Linux
 
Docker Compose | Docker Compose Tutorial | Docker Tutorial For Beginners | De...
Docker Compose | Docker Compose Tutorial | Docker Tutorial For Beginners | De...Docker Compose | Docker Compose Tutorial | Docker Tutorial For Beginners | De...
Docker Compose | Docker Compose Tutorial | Docker Tutorial For Beginners | De...
 
OpenShift Enterprise 3.1 vs kubernetes
OpenShift Enterprise 3.1 vs kubernetesOpenShift Enterprise 3.1 vs kubernetes
OpenShift Enterprise 3.1 vs kubernetes
 
Terraform vs Pulumi
Terraform vs PulumiTerraform vs Pulumi
Terraform vs Pulumi
 
Docker Swarm for Beginner
Docker Swarm for BeginnerDocker Swarm for Beginner
Docker Swarm for Beginner
 
Introduction to the Container Network Interface (CNI)
Introduction to the Container Network Interface (CNI)Introduction to the Container Network Interface (CNI)
Introduction to the Container Network Interface (CNI)
 
Understanding docker networking
Understanding docker networkingUnderstanding docker networking
Understanding docker networking
 
Using Rook to Manage Kubernetes Storage with Ceph
Using Rook to Manage Kubernetes Storage with CephUsing Rook to Manage Kubernetes Storage with Ceph
Using Rook to Manage Kubernetes Storage with Ceph
 
Management file and directory in linux
Management file and directory in linuxManagement file and directory in linux
Management file and directory in linux
 
Docker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting TechniquesDocker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting Techniques
 
Monitoring kubernetes with prometheus
Monitoring kubernetes with prometheusMonitoring kubernetes with prometheus
Monitoring kubernetes with prometheus
 
Basics of shell programming
Basics of shell programmingBasics of shell programming
Basics of shell programming
 
An Introduction To Jenkins
An Introduction To JenkinsAn Introduction To Jenkins
An Introduction To Jenkins
 
Kubernetes API - deep dive into the kube-apiserver
Kubernetes API - deep dive into the kube-apiserverKubernetes API - deep dive into the kube-apiserver
Kubernetes API - deep dive into the kube-apiserver
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Introduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageIntroduction to Docker storage, volume and image
Introduction to Docker storage, volume and image
 
Server configuration
Server configurationServer configuration
Server configuration
 

Semelhante a Unit 10 investigating and managing

Semelhante a Unit 10 investigating and managing (20)

lec4.docx
lec4.docxlec4.docx
lec4.docx
 
50 Most Frequently Used UNIX Linux Commands -hmftj
50 Most Frequently Used UNIX  Linux Commands -hmftj50 Most Frequently Used UNIX  Linux Commands -hmftj
50 Most Frequently Used UNIX Linux Commands -hmftj
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
Linux And perl
Linux And perlLinux And perl
Linux And perl
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
 
Linux tech talk
Linux tech talkLinux tech talk
Linux tech talk
 
Basics of unix
Basics of unixBasics of unix
Basics of unix
 
Examples -partII
Examples -partIIExamples -partII
Examples -partII
 
workshop_1.ppt
workshop_1.pptworkshop_1.ppt
workshop_1.ppt
 
Linux cheat sheet
Linux cheat sheetLinux cheat sheet
Linux cheat sheet
 
linux_Commads
linux_Commadslinux_Commads
linux_Commads
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
 
Group13
Group13Group13
Group13
 
101 3.2 process text streams using filters
101 3.2 process text streams using filters101 3.2 process text streams using filters
101 3.2 process text streams using filters
 
Linux
LinuxLinux
Linux
 
101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Terminal linux commands_ Fedora based
Terminal  linux commands_ Fedora basedTerminal  linux commands_ Fedora based
Terminal linux commands_ Fedora based
 
Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet
 

Mais de root_fibo

Unit 13 network client
Unit 13 network clientUnit 13 network client
Unit 13 network clientroot_fibo
 
Unit 12 finding and processing files
Unit 12 finding and processing filesUnit 12 finding and processing files
Unit 12 finding and processing filesroot_fibo
 
Unit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell scriptUnit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell scriptroot_fibo
 
Unit3 browsing the filesystem
Unit3 browsing the filesystemUnit3 browsing the filesystem
Unit3 browsing the filesystemroot_fibo
 
Unit 9 basic system configuration tools
Unit 9 basic system configuration toolsUnit 9 basic system configuration tools
Unit 9 basic system configuration toolsroot_fibo
 
Unit 8 text processing tools
Unit 8 text processing toolsUnit 8 text processing tools
Unit 8 text processing toolsroot_fibo
 
Unit 7 standard i o
Unit 7 standard i oUnit 7 standard i o
Unit 7 standard i oroot_fibo
 
Unit 6 bash shell
Unit 6 bash shellUnit 6 bash shell
Unit 6 bash shellroot_fibo
 
Unit 5 vim an advanced text editor
Unit 5 vim an advanced text editorUnit 5 vim an advanced text editor
Unit 5 vim an advanced text editorroot_fibo
 
Unit 4 user and group
Unit 4 user and groupUnit 4 user and group
Unit 4 user and grouproot_fibo
 

Mais de root_fibo (11)

Unit 13 network client
Unit 13 network clientUnit 13 network client
Unit 13 network client
 
Unit 12 finding and processing files
Unit 12 finding and processing filesUnit 12 finding and processing files
Unit 12 finding and processing files
 
Unit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell scriptUnit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell script
 
Unit3 browsing the filesystem
Unit3 browsing the filesystemUnit3 browsing the filesystem
Unit3 browsing the filesystem
 
Unit 9 basic system configuration tools
Unit 9 basic system configuration toolsUnit 9 basic system configuration tools
Unit 9 basic system configuration tools
 
Unit 8 text processing tools
Unit 8 text processing toolsUnit 8 text processing tools
Unit 8 text processing tools
 
Unit 7 standard i o
Unit 7 standard i oUnit 7 standard i o
Unit 7 standard i o
 
Unit 6 bash shell
Unit 6 bash shellUnit 6 bash shell
Unit 6 bash shell
 
Unit 5 vim an advanced text editor
Unit 5 vim an advanced text editorUnit 5 vim an advanced text editor
Unit 5 vim an advanced text editor
 
Unit 4 user and group
Unit 4 user and groupUnit 4 user and group
Unit 4 user and group
 
Unit2 help
Unit2 helpUnit2 help
Unit2 help
 

Último

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 

Último (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

Unit 10 investigating and managing

  • 1. RedHat Enterprise Linux Essential Unit 10: Investigating and Managing Processes
  • 2. Investigating and Managing Processes Upon completion of this unit, you should be able to:  Explain what a process is  Describe how to manage processes  Use job control tools
  • 3. What is a Process?  A process is a set of instructions loaded into memory  Numeric Process ID (PID) used for identification  UID, GID and SELinux context determines filesystem access • Normally inherited from the executing user
  • 4. Listing Processes  View Process information with ps  Shows processes from the current terminal by default  a includes processes on all terminals  x includes processes not attached to terminals  u prints process owner information  f prints process parentage  o PROPERTY,... prints custom information: • pid, comm, %cpu, %mem, state, tty, euser, ruser  Process states – running, sleeping, uninterruptable sleep, zombie.
  • 5. Finding Processes  Most flexible: ps options | other commands ps axo comm,tty | grep ttyS0 ps -ef  By predefined patterns: pgrep $ pgrep -U root $ pgrep -G student ● By exact program name: pidof $ pidof bash
  • 6. Example with cpu ps –Ao pcpu,pid,user,args | sort –k 1 –r |head -10
  • 7. Signals  Most fundamental inter-process communication  Sent directly to processes, no user-interface required  Programs associate actions with each signal  Signals are specified by name or number when sent: • Signal 15, TERM (default) - Terminate cleanly (stopping) • Signal 9, KILL - Terminate immediately (kill) • Signal 1, HUP - Re-read configuration files (reload) • Kill –l list info for singal • man 7 signal shows complete list
  • 8. Sending Signals to Processes  By PID: kill [signal] pid ...  By Name: killall [signal] comm ...  By pattern: pkill [-signal] pattern
  • 9. Scheduling Priority  Scheduling priority determines access to the CPU  Priority is affected by a process‘ nice value  Values range from -20 to 19 but default to 0  Lower nice value means higher CPU priority  Viewed with ps -Ao comm,nice ex: firefox & ps –Ao comm,nice |grep firefox
  • 10. Altering Scheduling Priority  Nice values may be altered...  When starting a process: $ nice -n 5 command  After starting: $ renice 5 PID renice 5 –p PID  Only root may decrease nice values
  • 11. Interactive Process Management Tools  CLI: top  GUI: gnome-system-monitor  Capabilities  Display real-time process information  Allow sorting, killing and re-nicing
  • 12. Job Control  Run a process in the background  Append an ampersand to the command line: firefox &  Temporarily halt a running program  Use Ctrl-z or send signal 17 (STOP)  Manage background or suspended jobs  List job numbers and names: jobs  Resume in the background: bg [%jobnum]  Resume in the foreground: fg [%jobnum]  Send a signal: kill [-SIGNAL] [%jobnum]
  • 13. Scheduling a Process To Execute Later  One-time jobs use at, recurring jobs use crontab Create at time crontab -e List at -l crontab -l Details at -c jobnum N/A Remove at -d jobnum crontab -r Edit N/A crontab -e  Non-redirected output is mailed to the user  root can modify jobs for other users
  • 14. Using at  Setting an at job: at [options] time  Options: -b run command only when the system load is low -d job# delete an at job from queue -f filename read job from a specified file -l list jobs for that user (all jobs for root) -m mail user quen job completes -q queuename send the jobs to a queue (a to z and A to Z)  Time formats: now, 17:00, +3 hours, +2 minutes, +2 days, +3 months, 19:15 3.12.10, midnight, 4PM, 16:00 +3 days, mon, tomorrow …  Show the at jobs queue of user: atq or at –l  Deletes at jobs from the jobs queue: atrm job# [job#] …
  • 15. Examples with at  Create an simple at job to run in 5 minutes later $ at now+5 minutes echo “I am running in an at job” > /tmp/test_cron [Ctrl-D]  Create an at job which read commands from a file and run at midnight $ at –f /tmp/myjob.sh midnight  Using echo to run multiple commands with at $ echo „cd /tmp; ls –a > /tmp/test_cron ‟ | at now+2 minutes  Listing all at jobs $ at –l $ atq
  • 16. crontab commands  Create/edit a user crontab: crontab –e  Create a user crontab by reading from file: crontab –e filename  Display user‟s crontab file: crontab –l  Delete user‟s crontab file: crontab –r  Edit a user‟s crontab file (for root only): crontab –e –u username
  • 17. Crontab File Format  Entry consists of five space-delimited fields followed by a command line 01 * * * * root cd /tmp && ls -laht  One entry per line, no limit to line length  Fields are minute, hour, day of month, month, and day of week  Comment lines begin with #  See man 5 crontab for details
  • 18. Examples of user crontabs  Run a command every hour from 8:00 to 18:00 everyday 0 8-18 * * * <command>  Run a command every 4 hours on the half hour (i.e 6:30, 10:30, 14:30, 16:30) everyday 30 6-16/4 * * * <command>  Run a command every day, Monday to Friday at 01:00, and doesn‟t report to syslog -0 1 * * 1-5 <command>  Run the command every Monday and Tuesday at 12:00, 12:10, 12:20, 12:30 0,10,20,30 12 * * 1,2 <command>  Run a command every 10 minutes */10 * * * * <command> echo “00 21 * * 7 root rm -f /tmp/*.log” >> /etc/crontab crontab -e 00 8-17 * * 1-5 du -sh $HOME >> /tmp/diskreport
  • 19. Grouping Commands  Two ways to group commands:  Compound: date; who | wc -l • Commands run back-to-back  Subshell: (date; who | wc -l) >> /tmp/trace • All output is sent to a single STDOUT and STDERR
  • 20. Exit Status  Processes report success or failure with an exit status  0 for success, 1-255 for failure  $? stores the exit status of the most recent command  exit [num] terminates and sets status to num  Example: $ ping -c1 -W1 localhost999 &> /dev/null $ echo $? 2
  • 21. Conditional Execution Operators  Commands can be run conditionally based on exit status  && represents conditional AND THEN  || represents conditional OR ELSE  Examples: $ grep -q no_such_user /etc/passwd || echo 'No such user' No such user $ ping localhost &> /dev/null > && echo “localhost is up" > || echo ‘localhost is unreachable’ localhost is up
  • 22. The test Command  Evaluates boolean statements for use in conditional execution  Returns 0 for true  Returns 1 for false  Examples in long form: test "$A" = "$B" && echo "string" || echo "not equal" $ test "$A" -eq "$B" && echo "Integers are equal“  Examples in shorthand notation: $ [ "$A" = "$B" ] && echo "Strings are equal" $ [ "$A" -eq "$B" ] && echo "Integers are equal"
  • 23. File Tests  File tests:  -f tests to see if a file exists and is a regular file  -d tests to see if a file exists and is a directory  -x tests to see if a file exists and is executable  [ -f ~/lib/functions ] && source ~/lib/functions
  • 24. File Tests (cont’) Options Mean -d file True if the file is a directory. -e file True if the file exists. -f file True if the file exists and is a regular file. -h file True if the file is a symbolic link. -L file True if the file is a symbolic link. -r file True if the file exists and is readable by you. -s file True if the file exists and is not empty. -w file True if the file exists and is writable by you. -x file True if the file exists and is executable by you. -O file True if the file is effectively owned by you. -G file True if the file is effectively owned by your group.
  • 25. Scripting: if Statements  Execute instructions based on the exit status of a command if ping -c1 -w2 station1 &> /dev/null; then echo 'Station1 is UP' elif grep "station1" ~/maintenance.txt &> /dev/null; then echo 'Station1 is undergoing maintenance' else echo 'Station1 is unexpectedly DOWN!' exit 1 fi