Connect with us

Masters of Computer Science

Background Processing in Linux. Here is what you need to know!

Published

on

Introduction of Process

  • Process is an instance of program. A new process is started when you gibe any command to Linux machine.
  • For a single program, there can be multiple processes.

Types of Processes

Foreground Processes

  • Run on the screen
  • Input from user is needed
  • Example: Office Programs

Background Processes

  • Run on background
  • Usually, input from user is not needed
  • Example: Antivirus

Running a Background Process

  • If a program / process is started from terminal, we can’t work on terminal up to the time when program is up and running.
  • Data intensive tasks can have lot of processing time which needs a lot of time to be completed. And holding terminal for such long time is not desirable
  • Also, if terminal is closed, process along with its child can also be terminated.
  • For avoiding this, you need to send the program to background and then only, terminal gets available to you.

How to start Linux Process in Background?

  • If process is in executin, press ctrl+z  and enter bg command. This will execute process in background as a job.
  • All background jobs can be seen by typing jobs command
  • To tun the process on foreground, we use command  “fg”
  • Syntax: fg jobname

Some Commands:

  • “bg” to esecute process in background
  • “fg” to run process on foreground
  • “top” tells user about all the running processes
  • “ps” command is use to see all the processes running under a user. E.g ps abhash [This is similar to task manager in windows]
  • “nice”
    • Nice commands prioritize the process in linux as per your requirements
    • This is niceness in linux , with value in range -20 to 19. Lower the nicensess value, higher the priority of the task.
    • Default value is 0
    • Syntax: nice-n “nice value” process-name
    • Ex: $ nice -9 19 bann
    • If there is process already running, the value can be renice. Syntax: renice “nice value” –p “PID”
  • “df” reports free disk space of file sysem
  • “free” command shows free and used memory (RAM)
Facebook Comments

10 Hits in 30 Days

DMCA
PROTECTED