11-26-2007
Quote:
Originally Posted by
porter
The create a single file does have the advantage of simplicity, and with daemons has the dual purpose of being used to contain the pid of the running instance. Take care to delete this file when your process terminates using atexit/trap or equivalent, and obviously requires a standard place to hold the file which is writeable by the process owner.
Exactly!
Adding to that,
once the pid is written to that file, revoke the write permission on the file and just make sure only read permission is available.
This is just a way to prevent accidental overwriting / deleting of the pid file
Quote:
The "ps" approach can also be used but you need to take care that you are not picking up some other process which either has that name within another string, is the process which is doing the search, or is part of a list of arguments or is yourself.
to this,
ps -fu $USERNAME would do
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
I am in a multi-user Linux environment at work. Other users easily run processes on my machine when my machine is idle, but when I try to use my machine, it is dead slow. The processes run by them always grab the top spot using 99% of my CPU time. Is there a way I can prevent others to run... (3 Replies)
Discussion started by: besharam
3 Replies
2. UNIX for Advanced & Expert Users
I have created a shell script.
I want to run the script in Autosys.
Please note my shell script runs as "$ ksh run.ksh"
How do I make autosys run this script at 5:00PM every day?
insert_job: abc job_type: c
box_name: run.box
command: ksh run.ksh
machine: mach1
#owner: mach1@mymach... (1 Reply)
Discussion started by: gram77
1 Replies
3. Shell Programming and Scripting
Hi
My five script run throgh crontab at same time at 6 clock.
Due to problem in the data load .Now I want to check time of load finish run these jobs. I create a script which check the load finish time but I have no idea how I run these JObs. This is very urget to me. Please reply me as soon... (3 Replies)
Discussion started by: Jamil Qadir
3 Replies
4. Shell Programming and Scripting
Hi!
I need to run my script for a specific number of time, as specified by the user: For instance, if the user specified 10, my script should run for until 10 seconds expire. How do I do this? (0 Replies)
Discussion started by: looza
0 Replies
5. Shell Programming and Scripting
how to find when last time a scrit has ran? (7 Replies)
Discussion started by: RahulJoshi
7 Replies
6. Shell Programming and Scripting
I have just written a Csh script and i want to find out how long does the script take to complete executing. Is there any codes which i can put into my script to capture its run time ? (9 Replies)
Discussion started by: Raynon
9 Replies
7. Shell Programming and Scripting
Hello
I am asked to run around 5-6 SQL queries in a shell script and take a note of the time taken to execute each query to a file. How do I get the time taken to run the individual SQL queries (2 Replies)
Discussion started by: vat1kor
2 Replies
8. Shell Programming and Scripting
I have an ETL process that triggers a shell script. This script picks the files created by the ETL process and does an SFTP. These are huge files. Due to infrastructure limitations, we need to trigger the actual SFTP part only during the 2nd, 16th, 31st and 46th minute of an hour. Please let me... (2 Replies)
Discussion started by: vskr72
2 Replies
9. Shell Programming and Scripting
I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies
10. UNIX for Beginners Questions & Answers
Hi All,
Would like to write a Script which will run between 11am to 3 pm and send the results to output.txt.
Please suggest. (2 Replies)
Discussion started by: vasuvv
2 Replies
LEARN ABOUT SUNOS
sched_getparam
sched_getparam(3RT) Realtime Library Functions sched_getparam(3RT)
NAME
sched_getparam - get scheduling parameters
SYNOPSIS
cc [ flag... ] file... -lrt [ library... ]
#include <sched.h>
int sched_getparam(pid_t pid, struct sched_param *param);
DESCRIPTION
The sched_getparam() function returns the scheduling parameters of a process specified by pid in the sched_param structure pointed to by
param.
If a process specified by pid exists and if the calling process has permission, the scheduling parameters for the process whose process ID
is equal to pid will be returned.
If pid is 0, the scheduling parameters for the calling process will be returned. The behavior of the sched_getparam() function is unspeci-
fied if the value of pid is negative.
RETURN VALUES
Upon successful completion, the sched_getparam() function returns 0. If the call to sched_getparam() is unsuccessful, the function returns
-1 and sets errno to indicate the error.
ERRORS
The sched_getparam() function will fail if:
ENOSYS The sched_getparam() function is not supported by the system.
EPERM The requesting process does not have permission to obtain the scheduling parameters of the specified process.
ESRCH No process can be found corresponding to that specified by pid.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SEE ALSO
librt(3LIB), sched.h(3HEAD), sched_getscheduler(3RT), sched_setparam(3RT), sched_setscheduler(3RT), attributes(5)
NOTES
Solaris 2.6 was the first release to support libposix4/librt. Prior to this release, this function always returned -1 and set errno to
ENOSYS.
SunOS 5.10 5 Oct 2001 sched_getparam(3RT)