Single Instance


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Single Instance
# 1  
Old 02-14-2006
Single Instance

Hi,

I have a script. I want only one instance of the script to be running at any point of the time. How can I do it.
what would be the exact format of the ps command for doing this. For example the name of my script is "Inst.sh"

Thanx in advance
# 2  
Old 02-14-2006
ps listing gives you all the processes that are running. If more than one instance of Inst.sh is running, you plan to kill the other instances ? Better would be to introduce a lock file concept rather than killing processes.

ps x | grep '[I]nst.sh' gives you the pid(s) of Inst.sh

See the lock file getting used in how to detect my script is already running and How to check if another instance of the process is running
# 3  
Old 02-14-2006
why to kill the other instances,
while booting the particular script itself just make a check if any of the previous instance is currently running if so dont boot the new instance.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Paste 2 single column files to a single file

Hi, I have 2 csv/txt files with single columns. I am trying to merge them using paste, but its not working.. output3.csv: flowerbomb everlon-jewelry sofft steve-madden dolce-gabbana-watchoutput2.csv: http://www1.abc.com/cms/slp/2/Flowerbomb http://www1.abc.com/cms/slp/2/Everlon-Jewelry... (5 Replies)
Discussion started by: ajayakunuri
5 Replies

2. UNIX for Advanced & Expert Users

How to check a single process instance is always running?

Hi, I want to write one program in C in Unix OS which will check the running status of a process time to time. If the process is stopped somehow by any means, it will ensure that the process is restarted and only one copy of the process image should run in memory at any point of time for the user.... (2 Replies)
Discussion started by: sanzee007
2 Replies

3. Shell Programming and Scripting

Help extracting single instance of numbers which repeat

Hi, the title isn't very descriptive but it'll be easier to explain what I need if I write out the coordinates from which I need to extract certain information: ATOM 2521 C MAM X 61 44.622 49.357 12.584 1.00 0.00 C ATOM 2522 H MAM X 61 43.644 49.102 12.205 ... (10 Replies)
Discussion started by: crunchgargoyle
10 Replies

4. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

5. Shell Programming and Scripting

Replace single quote with two single quotes in perl

Hi I want to replace single quote with two single quotes in a perl string. If the string is <It's Simpson's book> It should become <It''s Simpson''s book> (3 Replies)
Discussion started by: DushyantG
3 Replies

6. Shell Programming and Scripting

Keep the last instance of the record

Hi All, I have a input file like 1| abc 1| abcd 1| abcde 2| abc 2| abcd 3| abcde I want the output like 1| abcde 2| abcde Any help would be highly appreciated. Thanks in advance. (9 Replies)
Discussion started by: lrkp
9 Replies

7. Shell Programming and Scripting

What does : do in this instance

Guys please see below functions to return a status depending on user input. Both seem to work the same. The second way has a : line which i can't understand or see in a ksh manual anywhere. Instead of doing the variable change if its empty on this line the first function simply does it on the... (7 Replies)
Discussion started by: lavascript
7 Replies

8. Shell Programming and Scripting

getopts ... only allow a single instance of an argument?

Hi there, if i have a simple getopts like below ...how can i make it so that if somebody enters more than one -g argument for example, it will error with a " you cannot enter more than one -g" or something like that.? I want to only allow one instance of a -g or a -h etc .. while getopts... (1 Reply)
Discussion started by: hcclnoodles
1 Replies

9. Shell Programming and Scripting

replace first instance(not first instance in line)

Alright, I think I know what I am doing with sed(which probably means I don't). But I cant figure out how to replace just the first occurance of a string. I have tried sed, ed, and grep but can't seem to figure it out. If you have any suggestions I am open to anything! (3 Replies)
Discussion started by: IronHorse7
3 Replies

10. Shell Programming and Scripting

Single Instance of a Shell Script

Hi, I have a shell script. What should I do to allow only single instance of the script to be run by a user at a time. That is, Only one user can run that script at a given point of time. Please help.. Its very important for my project Thanks in advance (4 Replies)
Discussion started by: pathanjalireddy
4 Replies
Login or Register to Ask a Question