The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-20-2008
Rajat Rajat is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 29
Get pid

Hello people,
This question might seem to be a little naive but here it goes:
I want to know the PID of a script that is running in the background.
eg: There is a script called Data_Downloader.sh
I am using the command:
ps -ef | grep Data_Downloader.sh
But I am getting the output as
wrkarea 18524 9063 0 15:46:41 pts/4 0:00 grep Data_Downlaoder.sh
Thanks in advance.
  #2 (permalink)  
Old 08-20-2008
redoubtable redoubtable is offline
Registered User
  
 

Join Date: Aug 2008
Location: Portugal
Posts: 242
That means the script is no longer running.

If you wish to get the pid from within that script add a line like echo $$
  #3 (permalink)  
Old 08-20-2008
Rajat Rajat is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 29
Hello redoubtable (nice nick by the way),
the script runs for 30secs ... and I am running the script within this time itself. So not sure what the problem is.
  #4 (permalink)  
Old 08-20-2008
ynilesh's Avatar
ynilesh ynilesh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore, India.
Posts: 222
AFAIK it should show process details if process is running. It might have been complete or killed and then you checked ps. (Just a doubt)

When you fire "bg" command does it show that your script is running in background ?

- nilesh
  #5 (permalink)  
Old 08-20-2008
ynilesh's Avatar
ynilesh ynilesh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore, India.
Posts: 222
Do one thing..... Run script and immediately run ps command.
Dont waste your time in typing ps -ef

try this..
Code:
sh your_script.sh; ps -aux | grep your_script
  #6 (permalink)  
Old 08-20-2008
Rajat Rajat is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 29
Ok guys here is the latest update !!!
i'm running the script like this:
./Data_Downloader.sh &
i am doing ps -ef | grep Data_Downloader.sh | grep -v grep
but as usual with no luck at all!!!
I also tried it with ps -ef | grep Data_Downloader.sh as stated earlier but with no luck.
There is a sleep time of 60 secs now in the script and i beleive my typing speed is good enough to get me the results!!!
  #7 (permalink)  
Old 08-21-2008
Rajat Rajat is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 29
Is this because of the sleep time that is there? Does ps -ef list the processes that are sleeping because the manual says that it lists all the 'active' processes.
Sponsored Links
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 03:08 AM.


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