Wednesday 11 September 2013

Executing Background Jobs in Linux

Manage Background Jobs in Linux

when you execute a find command that might take a lot time to execute, you can put it in the background as shown below.

Appending an ampersand ( & ) to the command runs the job in the background.

     find / -type f -mtime -1000 >> /root/filelist.log &

Sending the current foreground job to the background using Ctrl + Z.

     find / -type f -mtime -1000 >> /root/filelist.log
     Ctrl + Z
     bg

Taking a job from the background to the foreground.

     fg
     find / -type f -mtime -1000 >> /root/filelist.log
     Ctrl + Z

View all the background jobs.

     jobs

     [1]+  Stopped    find / -type f -mtime -1000 >> /root/filelist.log

Kill a specific background job.

     fg %1
     kill %1

ref: http://www.thegeekstuff.com/2010/05/unix-background-job/


No comments:

Post a Comment