Bash Jobs

Published: 1/12/2009
 

Bash CLI Jobs

You should new fully understand what the CLI does and what it is used for. You will also know that some tasks you perform on the command line take some time to finish. When you use the 'find' command you will note that this takes some time whist the program looks through the file system. During this time the command Line is not assessable.

 

# find / -name “*.jpg” -print 2>/dev/null

 

This command will try to find all files within the filing system “/” ( The whole system ) with the jpg extension. There are parts of the filing system that you may not have access to. In this case the find command will return an 'Permission Denied' standard error. We are not interested in the error messages so we send them to a file that automatically throws them away.

During this time the command line is not accessible. To solve this problem we use the & symbol to force the command to run in the background.

 

# find / -name “*.jpg” -print 2>/dev/null &

 

This however still interrupt you with the standard output (Listing files found). The best way to stop this is to send the output to a new file.

 

# find / -name “*.jpg” -print 2>/dev/null 1>filesfound &

 

This will create a file called 'filesfound' with a list of all files found. The CLI will now be available for you to enter extra commands.

Note that when the job starts you will be presented with the job number and the process ID. If you wish to take control over the command enter the following command.

 

# %1

 

Where 1 is the job number given when starting the process. This will bring the job to the foreground. You can stop the job by selecting [Ctrl + z] combo. This will pause the job.

 

Task

Working in your groups, use the 'root' user to create the 'locate' database. Run the locate command. Find the error and and solve the problem. Run the command:

 

# locate jpg

 

Stop the process and then run the task in the background. Send the output to a file.

 

Related Posts

Linux File Structure Part 2

Last Updated: 1/12/2009
When you wish to use the CDROM drive it must first have a cdrom in the drive and data on the cdrom. To view the data you must mount the device to a given place of the Linux filing tree. Everything in Linux is a file. The whole partition of a hard dr
Read more...

 

Linux File Structure

Last Updated: 1/12/2009
Understanding the basic idea behind the Linux file structure can help but only if other people follow this idea!
Read more...

 

Pipe and Redirection

Last Updated: 1/12/2009
The command line is not only a tool for bashing out program names but an elegant and intelligent environment. Some programming languages can be typed directly into the command line. Also tasks that take some time to execute in the background leaving
Read more...

 

Beginners Guide to Vi

Last Updated: 1/12/2009
Beginners Guide to Vi
Read more...

 

Mounting a Drive

Last Updated: 1/12/2009
In Linux, like in UNIX, diskettes and CD-ROMs need to be mounted before they can be used. What mount does is to associate the devices (floppy or CD-ROM drives) to a mount point (a directory) in the root file system. The usual mount point for diskette
Read more...