LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-23-2006, 03:01 AM   #1
George2
Member
 
Registered: Oct 2003
Posts: 354

Rep: Reputation: 30
have to program to get process ID?


Hello everyone,


On Linux platform, if I want to get current process (for example, a shell script), are there any ways (for example, a command) to get the process ID without programming.


regards,
George
 
Old 08-23-2006, 03:20 AM   #2
BiThian
Member
 
Registered: Aug 2006
Location: Romania
Distribution: NetBSD 3.1
Posts: 118

Rep: Reputation: 15
"man ps" or (h)top
Try this: ps -e | grep name_process

Last edited by BiThian; 08-23-2006 at 03:23 AM.
 
Old 08-23-2006, 08:04 AM   #3
George2
Member
 
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30
Thank you BiThian,


Quote:
Originally Posted by BiThian
"man ps" or (h)top
Try this: ps -e | grep name_process

regards,
George
 
Old 08-23-2006, 08:08 AM   #4
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
pgrep and pkill are also worth looking into. From the manpage:
Quote:
NAME
pgrep, pkill - look up or signal processes based on name and other
attributes
 
Old 08-23-2006, 08:11 AM   #5
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
i usually do a

`ps aux`
 
Old 08-24-2006, 02:05 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
pid=$$
and some more text to avoid 10 char min limit in post; sigh ....
 
Old 08-24-2006, 03:07 AM   #7
kshkid
Member
 
Registered: Dec 2005
Distribution: RHEL3, FC3
Posts: 383

Rep: Reputation: 30
Quote:
Originally Posted by chrism01
pid=$$
and some more text to avoid 10 char min limit in post; sigh ....

and that $$ - is valid only for the current working shell
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Starting program during boot-process with option to do not so ... ruh31 Debian 6 02-10-2006 01:41 AM
Starting a program with a given process id DropSig Linux - Newbie 1 09-29-2004 08:41 PM
Process monitor in program ... joda Linux - Networking 1 06-10-2004 01:22 PM
what is this program/process? BajaNick Linux - General 3 07-07-2003 01:05 PM
How to determine whether a PROCESS is running, by a SHELL program? yuzuohong Linux - General 4 01-21-2003 08:41 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration