How to wakeup sleeping processes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to wakeup sleeping processes
# 1  
Old 10-23-2006
How to wakeup sleeping processes

Hi,
Could someone please tell me how to wakeup sleeping processes? (i.e. change the process status from "S" to "R" when viewing in ps command).

I ran a few programs in the background by "&" which went into "sleep" mode and I want them to run.

Any help will be greatly appreciated.

Steve
# 2  
Old 10-23-2006
Quote:
Originally Posted by stevefox
Hi,
Could someone please tell me how to wakeup sleeping processes? (i.e. change the process status from "S" to "R" when viewing in ps command).

I ran a few programs in the background by "&" which went into "sleep" mode and I want them to run.

Any help will be greatly appreciated.

Steve
try out

fg %<name of process>

eg

fg %sort will bring the background process sort into the foreground
# 3  
Old 10-24-2006
Thanks napolayan,

I tried by running the below in backgroud:

Code:
$ sleep 180 &
[1]     12059

$ ps -lfe | grep 12059 | grep -v grep
  1 S  infodba 12059 12043  0 168 24         517072c0   16         57021080 17:24:37 pts/tl    0:00 sleep 180

then did the below to bring it to foreground

Code:
$ fg %1

then check the status of the process but it was still in sleep mode:

Code:
$ ps -lfe | grep 12059 | grep -v grep
  1 S  infodba 12059 12043  0 168 24         517072c0   16         57021080 17:24:37 pts/tl    0:00 sleep 180

Am I doing something wrong?
# 4  
Old 10-24-2006
fg and bg is not for making the process sleep and wake up... it is to make the process to go background and bring the process to back in case if it require any inputs...

if the process is sleeping, check whether there is any wait command in the script, check why it is waiting if there is any wait... don't think the process will go into sleep without any wait
# 5  
Old 10-24-2006
Thanx mahendramahendr

Below is the program which I am running in the background:

Code:
$ more testwait.ksh
#!/bin/ksh

n=20000

while [ $n -gt 0 ]
do
  n=`expr $n - 1`
done

I not using any "wait" command but it still goes into sleep. Is there anything in the script above which makes it sleep?
# 6  
Old 10-24-2006
add echo $n inside the while loop... and see where it goes into sleep state. I guess it shows as S even if your process is doing something... because I can see that the script is actually displaying the $n value in screen, still I see the state as "S"

Don't think it is a problem, echo $n should solve your doubt.
# 7  
Old 10-24-2006
try
Code:
wait <pid of sleeping process>

to see if the processes terminated and are waiting to be reaped? fg should have brought them back and allowed them to terminate....
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Signal trapped during read resumes sleeping

Greetings. This is my first post in this forum; I hope y'all find it useful. One caveat: "Concise" is my middle name. NOT! :D I am almost done with a shell script that runs as a daemon. It monitors a message log that is frequently written to by a database server but it it works my client will... (2 Replies)
Discussion started by: jakesalomon
2 Replies

2. UNIX for Dummies Questions & Answers

GNU Linux sleeping processes in top command

hi all sleeping processes in the following output , are they doing anything , but consuming lot of sources, should I need to kill them , how to know , , what they are doing and the output says out of 260 processes only 9 are running , and 251 are sleeping , what does the sleeping means, can... (8 Replies)
Discussion started by: sidharthmellam
8 Replies

3. UNIX for Dummies Questions & Answers

Sleep command not sleeping for specified time.

Hi, I have ascript with a recursive funtion below. I have mentioned to sleep for 60minutes but it doesnt doing so. Its keep on running until if /elif conditions satiesfies. Can you pls help what is wrong here. funcstatus () { if then echo "`date` - Current status... (2 Replies)
Discussion started by: gaddamja
2 Replies

4. Shell Programming and Scripting

Sleep process not sleeping!

I had a script executing every hour to kill a process. I used loop rather than cron to execute it periodically. But now when I am trying to kill that sleep process of 1 hour its not getting killed. it is taking a new PID everytime I kill. To disable the script commenting is the only option... (1 Reply)
Discussion started by: nixhead
1 Replies

5. Shell Programming and Scripting

Help on sleeping the script

Hi all, How can i specify to sleep for 24 hours in a script Thanks Firestar (5 Replies)
Discussion started by: firestar
5 Replies

6. Solaris

Identifying and grouping OS processes and APP processes

Hi Is there an easy way to identify and group currently running processes into OS processes and APP processes. Not all applications are installed as packages. Any free tools or scripts to do this? Many thanks. (2 Replies)
Discussion started by: wilsonee
2 Replies

7. UNIX for Advanced & Expert Users

Monitoring Processes - Killing hung processes

Is there a way to monitor certain processes and if they hang too long to kill them, but certain scripts which are expected to take a long time to let them go? Thank you Richard (4 Replies)
Discussion started by: ukndoit
4 Replies

8. Shell Programming and Scripting

Unable to kill sleeping process

Hi, I'm trying to delete a sleeping process (parent ID is not 1) with "kill -9" command by the owner of the process (infodba) but it doesn't get killed. Is there any way of killing this process without killing the parent process or rebooting? (I'm using HP Unix B.11.11) $ ps -eflx | grep... (0 Replies)
Discussion started by: stevefox
0 Replies

9. Shell Programming and Scripting

perl: sleeping during a command

hello everyone, i am attempting to run the sleep function (i've also tried select) during the execution of a command to mimic a status. for example: # this is a terminal screen # here the process is executed # below this a status is displayed while the command executes like so:... (3 Replies)
Discussion started by: effigy
3 Replies
Login or Register to Ask a Question