2

Is it possible to hold/stop the bash script progress without to kill the process? ( by kill command ) or other command

For example this script - install_linux_pkgs.bash , will install Linux pkgs step by step

    ./install_linux_pkgs.bash

What I want is to stop ( HOLD / HANG ) the script progress externally but not to kill it

kill -l
1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL
5) SIGTRAP      6) SIGABRT      7) SIGBUS       8) SIGFPE
9) SIGKILL     10) SIGUSR1     11) SIGSEGV     12) SIGUSR2
13) SIGPIPE     14) SIGALRM     15) SIGTERM     16) SIGSTKFLT
17) SIGCHLD     18) SIGCONT     19) SIGSTOP     20) SIGTSTP
21) SIGTTIN     22) SIGTTOU     23) SIGURG      24) SIGXCPU
25) SIGXFSZ     26) SIGVTALRM   27) SIGPROF     28) SIGWINCH
29) SIGIO       30) SIGPWR      31) SIGSYS      34) SIGRTMIN
35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+3  38) SIGRTMIN+4
39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+8
43) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12
47) SIGRTMIN+13 48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14
51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10
55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-7  58) SIGRTMAX-6
59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2
63) SIGRTMAX-1  64) SIGRTMAX

2 Answers 2

5

You can stop the process with ctrl-z. Then do whatever you want in the terminal. To continue the process use fg.

Or from another terminal, use:

kill -19 <pid>

It sends SIGSTOP (signal number 19) to the process. This is not possible to catch for the process. To continue the process use:

kill -18 <pid>

This time it's SIGCONT that brings the process back in a running/sleeping state.

4
  • why not use the kill -15 , its also hang the proccess? Commented Jul 1, 2015 at 6:35
  • 15? SIGTERM? That doesn't hang the process. It sends the process the signal to exit by himself; the process can ignore that or exit cleanly. Both options don't provide a "pause" of the process. SIGSTOP and SIGCONT is the correct way to go.
    – chaos
    Commented Jul 1, 2015 at 6:37
  • If your process catches the signal you can also use SIGTSTP (20). It will be catchable for the process unlike SIGSTOP. But that depends on the process.
    – chaos
    Commented Jul 1, 2015 at 6:39
  • @maihabunash As written in the answer, use kill -18 <pid>.
    – chaos
    Commented Jul 1, 2015 at 8:27
0

I think you should be able to hit Ctrl+Z and it'll suspend the process. When you're ready to come back to it, just use fg command and your process will come back to life in the foreground. Or, you could issue a bg command and it'll resurrect your program in background (equivalent to /some/program &)

2
  • please follow what I am asking ( from the kill -l ) you see all the option , what the option that needed to hold the script ( with PID number ) Commented Jul 1, 2015 at 6:29
  • sorry. misread your question... Based on what I've read, @chaos's solution should do the trick. (superuser.com/questions/476873/… second answer)
    – dimaj
    Commented Jul 1, 2015 at 6:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .