Multi-tasking with UNIX

You have a command line…how can you possibly achieve multitasking?

Let’s say you have a HUGE Java source to compile (using the javac command), but at the same time you want to look through your schedule (nano schedule.txt).

The compilation will take time, and you cannot wait.

So, you run the compilation in the background while looking  through your schedule.

The “&” can be used to run a task in the background.

javac myProgram.java &

nano schedule.txt

You can use the ‘bg’ command to put a job in the back-ground. (you can stop a task and return to the shell using Ctrl + Z)

Here the VI text editor is opened. Then after hitting Ctrl+z, we return to the shell and VI is stopped. Running bg causes it to run in the background (although running a text editor in the background is useless).

bg => run a program in background

fg => run a program in foreground

jobs => list all jobs (background + foreground)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: