Re: Test if Script Already Running

2017-04-20 Thread Marko Rauhamaa
Jon Ribbens : > On 2017-04-20, Cameron Simpson wrote: >> For myself, I like mkdir. It is portable. It is atomic. It fails if >> the target exists. It works over NFS etc. It is easy. >> >> os.mkdir('lock') >> ... do stuff ... >> os.rmdir('lock') > > One downside to this is that if the proce

Re: Test if Script Already Running

2017-04-20 Thread Jon Ribbens
On 2017-04-20, Cameron Simpson wrote: > Others have pointed the way to an exact implementation. > > For myself, I like mkdir. It is portable. It is atomic. It fails if > the target exists. It works over NFS etc. It is easy. > > os.mkdir('lock') > ... do stuff ... > os.rmdir('lock') One dow

Re: Test if Script Already Running

2017-04-19 Thread Cameron Simpson
On 18Apr2017 19:31, Matt wrote: I have a number of simple scripts I run with cron hourly on Centos linux. I want the script to check first thing if its already running and if so exit. In perl I did it with this at the start of every script: use Fcntl ':flock'; INIT { open LH, $0

Re: Test if Script Already Running

2017-04-18 Thread Jon Ribbens
On 2017-04-19, Matt wrote: > I have a number of simple scripts I run with cron hourly on Centos > linux. I want the script to check first thing if its already running > and if so exit. > > In perl I did it with this at the start of every script: > > use Fcntl ':flock'; > INIT { >

Re: Test if Script Already Running

2017-04-18 Thread Erik
On 19/04/17 01:31, Matt wrote: In perl I did it with this at the start of every script: use Fcntl ':flock'; [snip] How can I do something like this in Python? >>> import fcntl >>> help(fcntl.flock) E. -- https://mail.python.org/mailman/listinfo/python-list

Test if Script Already Running

2017-04-18 Thread Matt
I have a number of simple scripts I run with cron hourly on Centos linux. I want the script to check first thing if its already running and if so exit. In perl I did it with this at the start of every script: use Fcntl ':flock'; INIT { open LH, $0 or die "Can't open $0 for lockin