|
|||||||||
| Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here. |
learn linux and unix commands - unix shell scripting |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
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 |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
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 |
| Sponsored Links | ||
|
|
|
#3
|
||||
|
||||
|
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. |
| Sponsored Links | ||
|
|
![]() |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Multiple lines in a single column to be merged as a single line for a record | Bhuvaneswari | Shell Programming and Scripting | 1 | 08-11-2011 04:16 AM |
| Replace single quote with two single quotes in perl | DushyantG | Shell Programming and Scripting | 3 | 04-07-2011 03:16 AM |
| getopts ... only allow a single instance of an argument? | hcclnoodles | Shell Programming and Scripting | 1 | 04-09-2009 11:04 AM |
| replace first instance(not first instance in line) | IronHorse7 | Shell Programming and Scripting | 3 | 02-07-2008 01:29 PM |
| Single Instance of a Shell Script | pathanjalireddy | Shell Programming and Scripting | 4 | 04-19-2005 09:42 AM |
|
|