shell Jobs
December 9th, 2008 at 2:24pm |
concept: only 1 foreground program can be running on a shell terminal, however several can run in the background. Here’s how.
- [program] &
launches the program directly into the background - CTRL+Z
suspends the program currently running in the foreground into stopped state into the background - jobs -l
lists current background programs - fg %[n]
puts into foreground the job number [n] - bg %[n]
makes program [n] run into the background. The program should already be backgrounded, however after CTRL+Z it is in stopped state, thus this command brings it back to running state
an alternative solution is command
kill -cont pidnr - there are stopped jobs
error message while attempting to log out notifies you that there are some jobs still hanging around. Use jobs and fg %[n] to terminate them correctly without data loss - kill %[n]
terminates [n] job - logout logout
logs out terminating all backgrounded jobs
NOTE: with this command only backgrounded jobs in stopped state will be terminated, not those in running state.
screen
screen is a tty detachable emulator. you can use it with command
screen [program] args
to list all program executed with screen command
screen -list
to reattach a program executed with screen command (pid is taken from previous command)
screen -r [pid][tty][host]
shortcuts are
CTRL+ad to detach a program using screen
CTRL+DD to detach a program using screen and logout (notice the capital D)
Related posts:
- Basic commands for GNU/Linux – BSD (part 2)
- How to write an interactive shell script
- Basic commands for GNU/Linux – BSD (part 1)
- change keyboard layout in shell
- Cron daemon – recurrent tasks
- Basic commands for working with VI (and VIM)
- VMware Workstation 6.5.3 on Ubuntu Karmic 9.10
Print This Post
|
Email This Post