4 ms·
If I may add a trick: ctrl-z - stops a program bg - sends the stopped program to the background fg - gets the program back to the foreground (interactive mod
by growt 14y ago
If I may add a trick:
ctrl-z - stops a program
bg - sends the stopped program to the background
fg - gets the program back to the foreground (interactive mode)
very useful in editor sessions or when you want to get rid of the endless download/scp that is blocking your terminal
- sp332 14y agoYou can also use "jobs" to see background and stopped tasks. If there are multiple jobs, you can use "fg 2" to foreground the second job on the list, etc.
- niggler 14y agoNote that each job gets an identifier (which you can see by running `jobs`). Other commands like `kill` can work with the id number by using %[id]. For example: $ some_command ^Z (hit control z) $ some_command_2 ^Z (hit control z) $ jobs [1]- Stopped some_command [2]+ Stopped some_command_2 $ kill %1 $ jobs [1]- Terminated: 15 some_command [2]+ Stopped some_command_2
- dminor 14y agoWay back in my college days, one of the student admins took down the CS department's server by forgetting the % and killing process 1 by mistake.
- ottbot 14y agoAnother nice job management tool is disown, which lets you log out of your session without killing the job (similar to starting the command with nohup)
- mpyne 14y agoAnd also, you can pass the -h flag to disown to leave the job in the job control table (i.e. you can still bring it to the foreground/suspend it/etc.), but still skip sending the SIGHUP on logout.
- signa11 14y agoi normally have this : fork() { (setsid "$@" &); } in myzshrc, and then start stuff with : fork firefox
- philsnow 14y agoI have my terminal emulator configured to set the URGENT ICCCM hint when it sees a bell character. When I realize a command I just entered is going to take a while, and I want to go look at something else on another workspace, I do this: $ alias b='echo -e "\a"' $ long_running_thing ^Z $ fg ; b [long_running_thing resumes] Then when the job completes, the terminal bell will ring and my window manager will get my attention.