jobs
Linux Commands - Managing System and Program Info

jobs


This will list the current jobs in the foreground or background.


Options

-l list PIDs

The example shows the top command placed in the background and then jobs is used to show programs in the background.

top &

[1] 17537

mike@ub:~$ jobs

[1]+ Stopped top



nice


nice works with the scheduling algorithm of the operating system to adjust the priority of individual programs on the system. A Linux system has a scheduling process where the operating system must adjust access to the processor for each program that is running whether it is a background job, a process waiting for a time slice or a program actively using the CPU. The problem is that CPU can only process one program at a time. Therefore to service many processes running on the system the CPU scheduling must allocate a time slice for each process and set priorities for those time slices. This whole process is dynamic and is constantly monitored by the scheduling of the CPU. The value of being dynamic is that any processes that have been waiting for a long period of time will get a elevated priority by the scheduler.

The nice command will allow you to set priorities for how commands are executed. The increment must be in the range of 1-19. If the user does not specify a number the number 10 is assumed. Any increment which exceeds 19 will receive the 19 priority. The lower the number, including negative numbers, the higher the priority. This means that the number 5 is a lower priority than the number -4. The lowest priority is 19 and the highest priority is -20. Only root is able to use the negative numbers. The syntax for nice is as follows:


nice -n increment command argument


Example:


nice -n +12 vi project.rtf


In this example nice decreases the number by 12 for the command vi. The argument is the file that vi will edit.



Here is an example outcome when a normal user tries to increase the priority using negative numbers.

mike@ub:~$ nice -n-10 vi test.rtf

nice: cannot set priority: Permission denied