[ProgClub programming] top: st : time stolen from this vm by the hypervisor

John Elliot V | ProgClub jj5 at progclub.org
Thu Jun 6 07:20:26 AEST 2019


On 5/6/19 12:23 pm, Roland Turner via programming wrote:
> Assuming that you're not ready to embrace systemd (which, despite the
> absurd documentation, is actually pretty simple for common cases):
> 
>     #! /bin/bash -e
> 
>     ...
> 
>     persistentDataDir=/var/lib/something
>     alarm() {
>      touch $persistentDataDir/alarm
>     }
>     trap alarm ERR
>     [ -f $persistentDataDir/alarm ] && exit 1
> 
>> 4. I want to make sure only one copy of my process runs at a time
> 
> Under the same assumption:
> 
>     #! /bin/bash -e
> 
>     ...
> 
>     ephemeralDataDir=/var/run/something
>     unlock() {
>      rmdir $ephemeralDataDir/lock
>     }
>     trap unlock EXIT
>     mkdir $ephemeralDataDir/lock

Thanks for those examples, very handy! I've written them up for John's
Linux Page:

https://www.progclub.org/wiki/John%27s_Linux_page#Stopping_a_script_from_running_if_it_previously_exited_due_to_error

-- 
|_|O|_| ProgClub
|_|_|O| Because every programmer needs a good club!
|O|O|O| https://www.progclub.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jj5.vcf
Type: text/x-vcard
Size: 231 bytes
Desc: not available
URL: <http://www.progclub.org/pipermail/programming/attachments/20190606/e720af08/attachment-0001.vcf>


More information about the programming mailing list