473,396 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Custom PID checking for process

I'm looking to utilize something to the effect of this code:

Expand|Select|Wrap|Line Numbers
  1. ps -ef | grep sc_serv | grep -v grep | awk '{print $2}' > sc_serv.pid
  2. cat sc_serv.pid
  3. 3447
  4. 3449
The first id it spits out is the screen process that I run the sc_serv command under, and that's fine, because killing that process is really what I want. Killing the second will just produce nothing.

What I'd really like is for when this system boots up, it will check for the PID file. I'm guessing if it exists, and its a fresh boot, then it will kill the file, and start it under the user specified (automagically). I don't think I would have to check if the process exists.

I was also wondering if it would be a good idea to monitor this process to test if its alive. I've not had issues with it dying on its own in the past, so I think I can forgo checking on it every now and then.

Id still like this ran under the specified user under 'screen' mode so that if need be i can interact with it. I also have some other console type programs which I will need to interact with.

Here's the sc_cast process start file:
Expand|Select|Wrap|Line Numbers
  1. cat ../scast
  2. cd $HOME/shoutcast_serv
  3. screen -A -m -d -S scast ./sc_serv
Would I just tag on the ps -ef... command at the end of this, and it'll create a pid for me, stored where i would like? Also I'd like to create a startup script which during boot time it will show: Starting Shoutcast Server ... [ OK ] etc type messages so that I can track it by log as well.

If making a 'service' call out of this would work, that would be nice too, so that I can do something like 'service shoutcast start' and 'service nsv start' (two main purposes for this script) then that would be awesome, but running these under the user I need would be priority - I don't want them running under 'root'.

Help is appreciated.
Jul 16 '07 #1
1 2910
Motoma
3,237 Expert 2GB
It seems like you are trying to re-invent the wheel. Take a look at the start-stop-daemon tool.
Jul 17 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: George Sakkis | last post by:
I downloaded the latest Komodo (3.1) and configured it for python 2.4 so that it doesn't show decorators and genexps as syntax errors, but background syntax checking doesn't seem to work at all for...
7
by: netclectic | last post by:
Hi folks, i've searched and searched and can't find any example of what i'm trying to do. Essentially (i think) i need to add a new operator to Number. I'm using eval to evaluate expressions...
3
by: | last post by:
I have created a web setup project for my ASP.NET application that works fine. Also, I have followed the instructions for using a custom action to launch a web page after the installation is...
0
by: ChopStickr | last post by:
I have a custom control that is embedded (using the object tag) in an html document. The control takes a path to a local client ini file. Reads the file. Executes the program specified in...
125
by: jacob navia | last post by:
We hear very often in this discussion group that bounds checking, or safety tests are too expensive to be used in C. Several researchers of UCSD have published an interesting paper about this...
1
by: Anthony Levensalor | last post by:
Hey guys! I'm writing a widget wherein I want the pages using it to be able to subscribe to events on it. I did my own research, not asking anyone to write it for me, just want to make sure I'm...
30
by: Tarique | last post by:
I have tried to write my custom scanf function on the lines of minprintf provided in K&R2.In the function myscanf() i access memory directly using the address passed to the function .Can it be...
5
by: gerry | last post by:
I am trying to create a custom container control that will only ever contain a specific type of control. At design time, when a control of a different type is added to the container I would like...
5
by: =?Utf-8?B?R2FyeSBMYXJpbWVy?= | last post by:
Created a Custom Validation Ctrl in EW2 to validate a text box entry. Want to make sure entry is evenly divisible by 7, and that value is not 0. However, args.IsValid = false, even if 77 is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.