The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Identifying and grouping OS processes and APP processes wilsonee SUN Solaris 2 09-30-2008 10:26 AM
Monitoring Processes - Killing hung processes ukndoit UNIX for Advanced & Expert Users 4 01-17-2008 04:30 AM
Unable to kill sleeping process stevefox Shell Programming and Scripting 0 10-30-2006 06:14 AM
sleeping less than a second Perderabo Answers to Frequently Asked Questions 0 09-14-2006 03:06 AM
perl: sleeping during a command effigy Shell Programming and Scripting 3 03-04-2005 09:04 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-23-2006
stevefox stevefox is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 115
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 (permalink)  
Old 10-23-2006
napolayan napolayan is offline
Registered User
  
 

Join Date: Oct 2006
Location: Bangalore, India
Posts: 41
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 (permalink)  
Old 10-24-2006
stevefox stevefox is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 115
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 (permalink)  
Old 10-24-2006
mahendramahendr mahendramahendr is offline Forum Advisor  
Registered User
  
 

Join Date: Dec 2005
Location: London
Posts: 222
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 (permalink)  
Old 10-24-2006
stevefox stevefox is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 115
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 (permalink)  
Old 10-24-2006
mahendramahendr mahendramahendr is offline Forum Advisor  
Registered User
  
 

Join Date: Dec 2005
Location: London
Posts: 222
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0