LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-11-2004, 09:23 AM   #1
Hackiller
LQ Newbie
 
Registered: Jun 2003
Location: Brazil
Distribution: Slackware 9
Posts: 24

Rep: Reputation: 15
How can I create a pid file from a backgournd process that I start?


Hey,
How can I create (in a bash script or c language) a pid file that has just the number of the pid in a file in /tmp/someting.pid or /tmp/something.tmp?!
Thanks
 
Old 05-11-2004, 03:32 PM   #2
dorian33
Member
 
Registered: Jan 2003
Location: Poland, Warsaw
Distribution: LFS, Gentoo
Posts: 591

Rep: Reputation: 32
'man pidof' ?
 
Old 05-12-2004, 07:56 AM   #3
Hackiller
LQ Newbie
 
Registered: Jun 2003
Location: Brazil
Distribution: Slackware 9
Posts: 24

Original Poster
Rep: Reputation: 15
Thanks... it helps me so much...
But, another question: and if I have more than one program started that has the same name but diferent options (like tail something > /dev/tty8 and tail something > /log.txt)... how can I take the pid just of the first one or the second one?
If I run pidof -s I get the first one but the next time I run that tail it will be the second one...
But if I have more tail's or another programs?
What can I do for get the specified pid?
Thanks a lot
 
Old 05-12-2004, 02:37 PM   #4
dorian33
Member
 
Registered: Jan 2003
Location: Poland, Warsaw
Distribution: LFS, Gentoo
Posts: 591

Rep: Reputation: 32
For instance if you run 2 'tail' instances you can use:
Code:
ps -eo pid,cmd |grep 'tail'
Next you can filter the output with awk.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting pid of a process!! vishamr2000 Programming 34 03-12-2015 07:12 AM
Start a Process with dedicated PID murder Linux - Newbie 5 08-15-2005 03:49 PM
how to get more process' info according to its PID? iclinux Programming 1 02-05-2005 05:30 AM
Is there a way to make a program create a pid file? blk96gt Slackware 1 10-29-2004 11:59 AM
ERROR: Couldn't write pid to pid file lawrencegoodman Linux - Newbie 2 02-13-2004 08:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:28 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