help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Self terminating code for bash scripts


From: adrelanos
Subject: Re: [Help-bash] Self terminating code for bash scripts
Date: Tue, 19 Mar 2013 15:32:04 +0000

Chris Down:
> On 19 March 2013 22:56, adrelanos <address@hidden> wrote:
>> When I am running a script, I wish, that it kills any previous instances
>> of itself in case it is still running. How can I do that?
> 
>     pids=( $(pgrep "$0") )
>     for pid in "address@hidden"; do
>         [[ "$pid" != "$$" ]] && kill "$pid"
>     done
> 
> Untested, it would be much better to just use a lock file anyway.
> 
> Chris
> 

Thanks, I am now using something similar. Works well.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]