Linux question about Ctrl-z
Moderator: Board moderators
-
- New poster
- Posts: 14
- Joined: Tue Feb 03, 2004 3:43 am
Linux question about Ctrl-z
Normally when I write programs, I log on using a SSH client to a remote server and I use emacs to write my program. Sometimes I accidentally hit C-z which suspends my currently running application. I can't figure out how to restart it, does anyone know how I can restart my suspended application? Thanks!
Re: Linux question about Ctrl-z
fgzacharyleung wrote:Normally when I write programs, I log on using a SSH client to a remote server and I use emacs to write my program. Sometimes I accidentally hit C-z which suspends my currently running application. I can't figure out how to restart it, does anyone know how I can restart my suspended application? Thanks!
Ciao!!!
Claudio
-
- Guru
- Posts: 1080
- Joined: Thu Dec 19, 2002 7:37 pm
Use Ctrl-Z to suspend a running job, Ctrl-C to kill it.
If you press Ctrl-Z, the system replies by giving jobnumber within square braces('[' and ']').
You can revive the job by entering 'fg %<job-id>', or definitely kill it by entering 'kill %<job-id>'. You can also let it continue in the background by entering 'bg %<job-id>.
To see all running and suspended jobs, enter 'jobs' from the command line. You will get a list of all running and suspended jobs.
Say we have an infinitly running program 'forever', then the following session should illustrate it all:
Hope it helps.
If you press Ctrl-Z, the system replies by giving jobnumber within square braces('[' and ']').
You can revive the job by entering 'fg %<job-id>', or definitely kill it by entering 'kill %<job-id>'. You can also let it continue in the background by entering 'bg %<job-id>.
To see all running and suspended jobs, enter 'jobs' from the command line. You will get a list of all running and suspended jobs.
Say we have an infinitly running program 'forever', then the following session should illustrate it all:
Code: Select all
knoppix@ttyp0[test]$ forever //start forever
//press Ctrl-Z
[1]+ Stopped forever //job-id is 1
knoppix@ttyp0[test]$ jobs //list of jobs
[1]+ Stopped forever
knoppix@ttyp0[test]$ fg %1 //revive in foreground
forever
//Ctrl-C to kill it
knoppix@ttyp0[test]$ jobs //no jobs
knoppix@ttyp0[test]$ forever & //start in background
[1] 12505 //job-id is 1
knoppix@ttyp0[test]$ forever //another job
//killed by Ctrl-C
knoppix@ttyp0[test]$ jobs
[1]+ Running forever & //job 1 still running in background
knoppix@ttyp0[test]$ fg %1 //pull it to foreground
forever
//Ctrl-Z
[1]+ Stopped forever
knoppix@ttyp0[test]$ bg %1 //revive in background
[1]+ forever &
knoppix@ttyp0[test]$ forever //another one
//Ctrl-Z
[2]+ Stopped forever
knoppix@ttyp0[test]$ kill %2 //kill suspended job
[2]+ Stopped forever
knoppix@ttyp0[test]$ jobs
[1]- Running forever & //background job still running
[2]+ Terminated forever
knoppix@ttyp0[test]$ kill %1 //kill it
-
- New poster
- Posts: 14
- Joined: Tue Feb 03, 2004 3:43 am