473,769 Members | 2,441 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom PID checking for process

1 New Member
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 2933
Motoma
3,237 Recognized Expert Specialist
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
2055
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 python 2.4. Even for correct files, it shows a "Syntax checking error: Error checking syntax: retval = 128, stderr=" alert. For python 2.3 it works fine (modulo the new 2.4 syntax of course). Both 2.3 and 2.4 are built from source on Cygwin, not...
7
5809
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 that can be entered by users, these expressions are defined by another app so i can't change the format of the expressions. I've managed to support the majority of operators by supplying my own functions that wrap the equivalent Math functions but...
3
5898
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 complete. This works great too, for web pages not associated with my new application. I would like to launch a web page that is part of the application that was just installed. The sample in MSDN shows using the following syntax:
0
1976
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 the ini on the client's PC. After the program has ended the control looks in a client side temp folder (specified by the ini file) for an image created by the executed program. If the image is there, then the control moves the file to a public folder...
125
6609
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 problem. http://www.jilp.org/vol9/v9paper10.pdf Specifically, they measured the overhead of a bounds
1
1622
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 on the right track here. Basically, I'm creating a private collection of listeners, then providing a mechanism for adding functions to that event. A dispatch function loops through the listeners, finds the right one,
30
3459
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 dangerous ? I am getting the correct output though.Any help is appreciated. /*Include Files*/ /*Assisting Functions*/ int flushln(FILE *f){ /*Code*/}
5
4127
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 to wrap the control in the proper control type - which is also a container. At design time I want to be able to turn this : <my:container> <asp:textbox />
5
1280
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 entered in text box. Tag and script that were added to page follow: <asp:CustomValidator id="CustomValidator1" runat="server" ClientValidationFunction="ClientValidateSerial3" ControlToValidate="SerialNumber3" Display="Dynamic" ErrorMessage="Entry...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9998
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8876
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.