Please enable JavaScript.
Coggle requires JavaScript to display documents.
Unix (26 (Background
sort < bigfile > results & (sleep…
Unix
26
- Background
sort < bigfile > results &
-
-
-
- UNIX vs BSD vs GNU-only
UNIX: Standard Option, Posix Option
-
-
-
Which processes are displayed?
ps processes associated with your userid and your terminal
ps -a processes associated with any userid and a terminal
ps -e all processes (includes daemons) :<3:
ps -p pid process with process ID pid
ps -u userid processes associated with specified userid
Which data columns are displayed?
ps PID TTY TIME CMD
ps -f UID PID PPID C TTY TIME CMD :<3:
ps -F UID PID PPID C SZ RSS STIME TTY TIME CMD
ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
ps -ly S UID PID PPID C PRI NI RSS SZ WCHAN TTY TIME CMD
Particularly Useful Combinations
ps display your own processes
ps -ef display all user processes, full output
ps -a display all non-daemon processes
ps -t - display all daemons (only)
x. Monitoring System Processes
top, prstat
top [-d delay] [-n count][-p pid[, pid]...]
*q, h(?), <space>
$top -d 10 -n 6 (run each 10 second, and only in 60s)
0.SYSTEM CALL PURPOSE
fork create a copy of the current process
wait wait for another process to finish executing
exec execute a new program within the current process
exit terminate the current process
kill send a signal to another process
open open a file for reading or writing
read read data from a file
write write data to a file
close close a file
-
- Suspending A Job: fg (^Z => send susp signal)
!!!^C is kill
- Suspending A Shell: suspend
suspend [-f]
- Job Control VS. Multiple Windows
-
- Moving a job to the foreground: fg
fg; fg %[job]; %[job]; fg %m; fg %?game (? in command)
% = fg = fg % = fg %+
fg %-
- Moving a job to the backgroud: bg
bg [%job..] => bg %2 %5 %6
Common
-
TERMINAL SETTINGS
stty tostop suspend background jobs that try to write to the terminal
stty -tostop turn off tostop
JOB CONTROL COMMANDS
jobs display list of jobs
ps display list of processes
fg move job to foreground
bg move job to background
suspend suspend the current shell
^Z suspend the current foreground job
kill send signal to job; by default, terminate job
VARIABLES
echo $$ display PID of current shell
echo $! display PID of the last command you moved to the background
SHELL OPTIONS: BASH, KORN SHELL
set -o monitor enable job control
set +o nomonitor turn off monitor
set -o notify notify immediately when background jobs finish
set +o nonotify turn off notify
SHELL VARIABLES: TCSH, C-SHELL
set listjobs list all jobs whenever a job is suspended (Tcsh only)
set listjobs long listjobs with a long listing (Tcsh only)
set notify notify immediately when background jobs finish
set nonotify turn off notify
-