Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
05-06-2014, 02:56 PM
|
#1
|
Member
Registered: Sep 2008
Posts: 546
Rep:
|
auto-creating a pid file when starting a process
I'm running ffmpeg-2.1.4-1 on a fedora 20 web server
I start ffmpeg by running a single (long) command in the console and I usually either put a '&' on the end to background it or I run it in a screen and then detach. It's not started by /etc/init.d/blah-de-blah. Is there a way to make ffmpeg create a pid file when it's started? ie: /var/run/ffmpeg.pid or similar.
I see from digging around that ffmpeg creates a pid but it's a number which changes every time ffmpeg is started.
To create a pid file do I need to modify the ffmpeg command? or does it have to be done by a script? I have seen a few script examples on google but they all refer to the /etc/init.d/program start method and don't fit a single command scenario. Thanks for any help.
|
|
|
05-06-2014, 05:54 PM
|
#2
|
Member
Registered: Dec 2004
Location: Yo Momma's house
Distribution: Fedora Rawhide, ArchLinux
Posts: 518
Rep:
|
you can use "pidof " to find the pid of any running program. So you can do "ffmpeg <some options> & pidof ffmpeg > /tmp/ffmpeg.pid"
|
|
|
05-06-2014, 07:19 PM
|
#3
|
Senior Member
Registered: Nov 2004
Distribution: Mint, MX, antiX, SystemRescue
Posts: 2,337
|
Code:
nohup sleep 30 & echo $! > pidfile
Substitute your ffmpeg command for "sleep 30" in the example above.
|
|
|
05-07-2014, 05:02 AM
|
#4
|
Member
Registered: Sep 2008
Posts: 546
Original Poster
Rep:
|
@DJ: thankyou for your advice DJ, your suggestion worked, ffmpeg is now creating a pid file.
Last edited by tonj; 05-07-2014 at 05:56 AM.
|
|
|
05-09-2014, 09:06 AM
|
#5
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912
|
Note: the pidof can list multiple process numbers if there are multiple instances of the application running. It does not indicate WHICH one is the one you just started.
Only the solution in post #3 will do that, as only the shell knows what the pid was of the process it just started.
|
|
|
05-09-2014, 03:36 PM
|
#6
|
Senior Member
Registered: Aug 2007
Location: Zurich, Switzerland
Distribution: Gentoo
Posts: 1,001
Rep:
|
Please set this thread as solved - thx
|
|
|
All times are GMT -5. The time now is 05:56 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|