How to pause process running under nohup?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to pause process running under nohup?
# 1  
Old 04-04-2014
How to pause process running under nohup?

Hi ALL,

Is there any way to pause a running process under nohup ?
I have fired a build commands with required flags under nohup as below. now how can
I pause the started build process.

nohup make DEVICE=ap DEBUG=1 &

I understand we can use ctrl + z to pause a foreground process but no idea about background.


Thanks.......................
# 2  
Old 04-04-2014
You might find that sending signal SIGSTOP to the process might suffice.

On my server, it is signal number 17, so:-
Code:
kill -17 process-id

For me signal SIGCONT to continue is 19.

Have a look at man signal top confirm the signals and their number for your installation, just to be sure. Do lots of testing too.



I hope that this helps,
Robin
Liverpool/Blackburn
UK
# 3  
Old 04-04-2014
Thanks Robin for the reply.
can we map this signal generation to a hot key some how ? i need a convenient way of doing this .
where there are multiple parallel processes running under make ,i need to send signal all those processes and is not
convenient to me. i need a way similar to cntrl+z which should collect all the pids info under nohup and
send SIGSTOP in one go.
# 4  
Old 04-04-2014
When you put something into the background (with or without nohup) you effectively disconnect it from the terminal. You could bring it back under terminal control by bringing it back into the foreground again.

When you start a process in the background from the command line, you will see the following sort of thing on the screen:-
Code:
sleep 500 &
[1]     10665

The number in square brackets is the job id and the number after is the process id. You can bring it back to the foreground with the command:-
Code:
fg %1

... or ...
Code:
fg 10665

So, use a percentage % marker to show it is the job id, or just use the process id. You will then be able to suspend it with a CNTL-Z as usual.

To restart it in the foreground, it is just as before. You can restart it in the background as either
Code:
bg %1

... or ...
Code:
bg 10665

I'm not sure about programming a keystroke to fire of a mass suspend. You might be able to do that with trap on signal 18, but then you disable CNTL-Z from your running shell.


I'm not sure if this is going to be easy to acheive. Could you not code up a function for the above suggestion, something like:-
Code:
$ cat newfunc
#!/bin/ksh

suspall()
{
jobs | tr -d "[]" | while read jobid rest
do
   kill -17 %$jobid
done
}

If you either include this in your .profile or have in in a script you can source in like this . newfunc, then from the command line, you would be able to do the following:-
Code:
$ . newfunc
$ sleep 500 &
[1]     266546
$ sleep 500 &
[2]     221692
$ sleep 500 &
[3]     123282
$ sleep 500 &
[4]     221416
$ sleep 500 &
[5]     174586
$ suspall
[1] + Stopped (SIGSTOP)        sleep 500 &
[2] - Stopped (SIGSTOP)        sleep 500 &
[3]   Stopped (SIGSTOP)        sleep 500 &
[4]   Stopped (SIGSTOP)        sleep 500 &
[5]   Stopped (SIGSTOP)        sleep 500 &
$




Does this help?


Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Nohup not give expected output. Non-stop running process

Hello, I am trying to make a bash script, I tested nohup but it did not help me. My code is: ffmpeg -i $input_url -c:v copy -c:a copy -listen 1 -f mpegts http://localhost:port/live/test When I open it in VLC, it starts feeding my screen and I see bitrate values. When I stop watching it,... (4 Replies)
Discussion started by: baris35
4 Replies

2. UNIX for Advanced & Expert Users

Running process in nohup

Hi All, I am facing issue in running a process in nohup. I ran a process in terminal since it is taking too long to complete I need to make it as background and nohup. I tried below and was able to make it in back ground 1. Cntrl + Z 2. bg I am using Korn Shell so disown is not working... (5 Replies)
Discussion started by: arunkumar_mca
5 Replies

3. UNIX for Dummies Questions & Answers

How to get a timestamp when running nohup & from a shell?

Hi, I am running nohup cp & in a shell script. How do I get a timestamp so I can get a timing of how long the copy took? Roughly, the script does something like below: date nohup cp -rp /files/source /files/target & date I am mainly wanting to know how long it took for the... (9 Replies)
Discussion started by: newbie_01
9 Replies

4. Shell Programming and Scripting

Error while running script using nohup

Hi, I am running the below script. When i run the script normally it executes fine but when i run the same script using nohup it throws an error as getStatus.sh: syntax error at line 3: `(' unexpected . Can you let me know why it is so? while do . $(dirname $0)/include.sh cd... (2 Replies)
Discussion started by: vignesh53
2 Replies

5. AIX

Query on running script with nohup

Hi, I'm trying to run database restore script with the nohup command as it will run for long hours since if I run it normally, the putty session will become inactive and the restore gets terminated. The command I use is nohup db2 -tvf FBR_NODE0000.scr -z FBR_NODE0000.log & But the problem is... (2 Replies)
Discussion started by: vkcool.17
2 Replies

6. Shell Programming and Scripting

Usage of NOHUP - How to keep the child process running even if I close the Server connection

Hi. ! When I use the 'NOHUP' along with the '&', the process will be running in the background. Even when I attempt to close (Meaning 'EXIT') the session (say PUTTY in this case), it wont exit unless the process is completed. But, say when I forcefully terminate the session (SHUT DOWN the... (2 Replies)
Discussion started by: WinBarani
2 Replies

7. UNIX for Advanced & Expert Users

nohup and background process

What is the difference between running a process using nohup and running a process in background ? Please explain (6 Replies)
Discussion started by: srksn
6 Replies

8. Shell Programming and Scripting

pid of nohup process

I want to print the pid of a nohup process to a file so later I can use the list of pid's in that file to stop the background processes again. I use ksh on AIXv5.3: nohup /start/script.ksh 1>/dev/null 2>&1 print $$ > .pid nohup /start/script2.ksh 1>/dev/null 2>&1 print $$ >> .pid But... (2 Replies)
Discussion started by: rein
2 Replies

9. UNIX for Dummies Questions & Answers

how to pause another process?

I guess I posted in wrong forum before. How do I pause another process and then restart it on linux? The other process doesn't listen for anything. Thanks for any help you can offer. Dane :confused: (1 Reply)
Discussion started by: daneensign
1 Replies

10. Shell Programming and Scripting

nohup process hangs

Hi All, I tried searching for this, but I have yet to find anything useful. So here goes, if a script executed from another script with nohup & hangs, does it affect the parent script? Reason I ask, we have a windows box with NFS, and we use it to store some of our files. Currently, I mount the... (2 Replies)
Discussion started by: Sully
2 Replies
Login or Register to Ask a Question