Skip to Main Content

How Docs

UW-specific

Manage Job Control in UNIX

NOTE: This document refers to software or hardware that is not currently supported by the University of Wyoming Information Technology Client Support Services. Although the information is believed to be correct, be aware that since no support is available, this information may be out-of-date or possibly no longer valid.

Introduction

UNIX is a multi-tasking system that allows you to run multiple jobs, programs, or processes at the same time. UW IT requests that only one computationally intensive job is run at a time per user, however. There are some simple commands to control your foreground and background jobs as well as determine the status of your jobs and processes. A foreground job is one with which you are currently interacting. A background job is any job with which you are not currently interacting.

Checking on the Status of your Jobs

The command jobs is used to check on the status (and number) of your jobs. If on FRONTIER (formerly ASUWlink) you type jobs you will usually get nothing listed. This is because most people will not have a job in the background. If you do have something in the background, however, jobs output may look something like this:

frontier:˜> jobs
[1] - suspended vi .forward
[2] + suspended vi sas_data.sas
[3] running lynx http://www.uwyo.edu

The first number in brackets enumerates the jobs in the background for you. The suspended part is the status of the job and the last part, vi .forward, is the name of the background job. This example has two jobs in the background. Both are suspended. The plus sign is in front of the name of the current job. The minus sign is in front of the name of the previous job.

Putting a Job in the Background

It is possible to start any job in the background and return control to the terminal by just appending the & character to command. An example would look like this:

frontier:˜> lynx http://www.uwyo.edu &

You can also put a job currently running into the background by typing <Ctrl>+z. This will suspend the job and put it in the background. Note, this control character may be changed, see document "How to Use UNIX Control Characters" for more information.

Moving a Job to the Foreground

To put a job to the foreground, type fg %jobnumber. An example would be moving the previous vi sas_data.sas job to the foreground by typing:

frontier:˜>fg %2

Replacing the digit 2 in the previous example with a - (dash) will bring the job indicated by the minus (-) in the display to the foreground. Using a % character in place of the 2 will put the job indicated by the plus (+) in the display in the foreground.

Killing a Job

To kill a job is to stop the job right where it is. If you have not saved the output of that particular job, killing a job will not save anything. Killing a job is not an elegant way to end the job. Instead, it is much better to bring a job to the foreground and exit it naturally.

To kill a job, type kill %jobnumber. Here is an example that will kill the previous vi .forward job:

frontier:˜>kill %1

You may sometimes need to add the switch -9 to the kill command if a job will not die. <Ctrl>+c will send an interrupt signal to a running job. This has the effect of killing it. Note, this control character can be changed, see the UNIX Control Characters How To (www.uwyo.edu/askit/displaydoc.asp?askitdocid=259&parentid=1) for more information. Here is an example of this command:

frontier:˜>kill %1 -9

Process Priority

All processes have a priority assigned to them. By default, your jobs and processes are 10. A higher priority number means lower priority. Any processes found running on the system with a total of more than 5 minutes of system time used will be nice'd (priority set down). Processes found with over 60 minutes of system time used that are not nice'ed will be kill'ed.

nice command arguments is the command syntax for this. An example would be to make a program called bigjob run with the command option -o at a lower priority:

is the command syntax for this. An example would be to make a program called run with the command option at a lower priority:

frontier:˜> nice bigjob -o

Checking on Processes

The ps command is used to check on processes. An example with the results looks like:

frontier:˜> ps
PID TTY TIME CMD
3427 pts/12 0:00 zsh

The first column, PID, is the process ID. The second column, TTY, is the port on which this process had been started. The third column, TIME, is the amount of CPU time the process has used. The fourth column, CMD, is the name of the command being run.

Running Processes While Logged Out

Normally, upon log out a hang-up signal (HUP) is sent to all processes started during that session. It is possible, however, to continue a process even after you have logged out. This may be beneficial for particularly lengthy processes. The shell command used to continue a process is nohup. Again, we ask you to nice any computationally intensive process. An example would be:

frontier:˜> nohup nice bigjob &

The output from a nohup'ed command will be sent to a file called nohup.out, unless otherwise redirected. You can no longer have command line interaction with a job that has been nohup'ed. The nohup'ed process will run to completion or until it is killed. To find such jobs use the ps -ef | grep username command.


 

Reviewed: 0706 By: CD

Additional help with the installation and configuration of
UW-supported software is available:
Faculty/Staff
Contact the IT Help Desk at 766-HELP (4357), option 1
Email UserHelp@uwyo.edu
Contact your IT user consultant
(www.uwyo.edu/infotech/services/helpdesk/uc/)

Students
Email ASU-IT@uwyo.edu
Contact the IT Help Desk at 766-HELP (4357), option 1
Come to the student computer lab in the lobby of the
Information Technology Center.

Footer Navigation

University of Wyoming
 
1000 E. University Ave. Laramie, WY 82071 // UW Operators (307) 766-1121 // Contact Us