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

Jevan Pipitone discussion-email-lists at jevan.com.au
Thu Jun 6 15:20:54 AEST 2019


Maybe this could be used?

https://www.cyberciti.biz/tips/find-out-if-file-exists-with-conditional-expressions.html

|[ -f ||$ephemeralDataDir/lock ] && echo "File exist" || echo "File does not 
exist" There's probably a way of doing it with a file instead of a 
directory. "[[ works only in Bash, Zsh and the Korn shell" Jevan. |

On Thu. 06-Jun.-19 3:15 pm, John Elliot V | ProgClub wrote:
> Hey Jevan.
>
> I note that it's your birthday today, so happy birthday!
>
> So thanks for your ideas but you can't use a file and 'touch', because
> Roland's code relies on 'mkdir' failing if the directory already exists;
> 'touch' doesn't fail in the same way.
>
> But as we've discovered we're probably best off finding a solution with
> 'flock'.
>
> Or you could just do what I do to avoid concurrency issues, and run your
> script manually in screen... ;)
>
> May the Force be with you,
> John Elliot V
>
> On 6/6/19 3:10 pm, Jevan Pipitone wrote:
>> I notice your lock is a folder (directory) which either exists or is
>> removed.
>>
>> A lock could alternatively be a blank (0 byte) file, like what you are
>> doing for your "alarm".
>>
>> https://www.progclub.org/wiki/John%27s_Linux_page#Stopping_a_script_from_running_if_it_previously_exited_due_to_error
>>
>> Would the following code work for lock?:
>>
>> ephemeralDataDir=/var/run/something
>> unlock() {
>>    rm $ephemeralDataDir/lock
>> }
>> touch $ephemeralDataDir/lock || exit 1;
>> trap unlock EXIT
>>
>> See:
>>
>> https://www.progclub.org/wiki/John%27s_Linux_page#Make_sure_only_one_instance_of_a_script_is_running_at_a_time
>>
>> Original Code:
>>
>> ephemeralDataDir=/var/run/something
>> unlock() {
>>    rmdir $ephemeralDataDir/lock
>> }
>> mkdir $ephemeralDataDir/lock || exit 1;
>> trap unlock EXIT
>>
>> I don't know whether there are any benefits of using a folder or using a
>> 0 byte file, for a lock status?
>>
>> Jevan.
>>
>>
>> On Thu. 06-Jun.-19 7:20 am, John Elliot V | ProgClub wrote:
>>> 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
>>>
>>>
>>> _______________________________________________
>>> ProgClub programming
>>> programming at progclub.org
>>> https://www.progclub.org/cgi-bin/mailman/listinfo/programming
>>> https://www.progclub.org/
>> -- 
>> Signature
>>
>>
>> Volunteer Work Only (but you can make money)
>> MIT SE (UC), GradDip IT (UC), BSc (ANU),
>> GradCert Rsch Methods & Des (UC)
>>
>> I am here for online friends, hobbies, volunteer work, and working on
>> business ideas, and I am on Centrelink Disability Support Pension
>> (Schizophrenia & Aspergers). I suspect that what will probably work is
>> people who are on a Centrelink payment such as unemployed, disability,
>> or retired, since they can benefit from me and since it allows me to
>> give back to Centrelink, and also, if female friends then age 49+ and
>> less attractive so that they will find me attractive, also probably
>> overweight since I am overweight. However I can also work with highly
>> skilled people since I can make use of what I get from them that is
>> useful for me to be able to work with interesting concepts. Me:
>> Computing Researcher, Self Employed, Innovation, Management, Canberra
>> Australia. Interests: Especially things involving the use of a computer.
>> Creating, Doing, Improvising, Analysing for Improvement: Computer
>> Programming Open Source including C#/VB.NET, CSS, HTML, Javascript, MS
>> Visual Studio, My/MS Sql, PHP, WinForms, WPF. 3d animation, Acting
>> Improvisations, Audio Podcasts, Business & Startups, Chat, Creative
>> Writing & Poetry, Creativity, Dancing, Debating, Decisions, Digital Art,
>> Discussion of Topics, Electronic Music Composition/Creation (FL Studio),
>> Engineering, Friends, Ideas, Information Analysis, Innovation, IT
>> Tuition, Jazz Piano, Jazz Singing Male Baritone & Choir & Karaoke,
>> Management, PC Support, Photography, Public Speaking, Reading online
>> science magazines and emails, Research, Science, Making YouTube Videos.
>> Friendship with adults via phone, Email, Online Chat, anything we can
>> make and send each other and collaborate on. Note: For our interactions,
>> collaborations, hobbies, volunteer work, etc to turn out successful, it
>> may be necessary for there to be a financial cost to me in order for you
>> or your organization to make it work, so let me know what you suggest.
>>
>> Web: http://www.jevan.com.au/
>> Email: email5 at jevan.com.au <mailto:email5 at jevan.com.au>
>> Tel: (02) 6152 8010 (or +61 2 6152 8010)
>> LinkedIn: http://www.linkedin.com/in/jevanpipitone
>> Facebook: http://www.facebook.com/jevanpipitone
>> GitHub: http://www.github.com/jevanpipitone
>> Twitter: http://www.twitter.com/jevanpipitone
>> Canberra, Australia
>>
>>
>>
>> _______________________________________________
>> ProgClub programming
>> programming at progclub.org
>> https://www.progclub.org/cgi-bin/mailman/listinfo/programming
>> https://www.progclub.org/
>>
>
> _______________________________________________
> ProgClub programming
> programming at progclub.org
> https://www.progclub.org/cgi-bin/mailman/listinfo/programming
> https://www.progclub.org/
-- 
Signature


Volunteer Work Only (but you can make money)
MIT SE (UC), GradDip IT (UC), BSc (ANU),
GradCert Rsch Methods & Des (UC)

I am here for online friends, hobbies, volunteer work, and working on 
business ideas, and I am on Centrelink Disability Support Pension 
(Schizophrenia & Aspergers). I suspect that what will probably work is 
people who are on a Centrelink payment such as unemployed, disability, 
or retired, since they can benefit from me and since it allows me to 
give back to Centrelink, and also, if female friends then age 49+ and 
less attractive so that they will find me attractive, also probably 
overweight since I am overweight. However I can also work with highly 
skilled people since I can make use of what I get from them that is 
useful for me to be able to work with interesting concepts. Me: 
Computing Researcher, Self Employed, Innovation, Management, Canberra 
Australia. Interests: Especially things involving the use of a computer. 
Creating, Doing, Improvising, Analysing for Improvement: Computer 
Programming Open Source including C#/VB.NET, CSS, HTML, Javascript, MS 
Visual Studio, My/MS Sql, PHP, WinForms, WPF. 3d animation, Acting 
Improvisations, Audio Podcasts, Business & Startups, Chat, Creative 
Writing & Poetry, Creativity, Dancing, Debating, Decisions, Digital Art, 
Discussion of Topics, Electronic Music Composition/Creation (FL Studio), 
Engineering, Friends, Ideas, Information Analysis, Innovation, IT 
Tuition, Jazz Piano, Jazz Singing Male Baritone & Choir & Karaoke, 
Management, PC Support, Photography, Public Speaking, Reading online 
science magazines and emails, Research, Science, Making YouTube Videos. 
Friendship with adults via phone, Email, Online Chat, anything we can 
make and send each other and collaborate on. Note: For our interactions, 
collaborations, hobbies, volunteer work, etc to turn out successful, it 
may be necessary for there to be a financial cost to me in order for you 
or your organization to make it work, so let me know what you suggest.

Web: http://www.jevan.com.au/
Email: email5 at jevan.com.au <mailto:email5 at jevan.com.au>
Tel: (02) 6152 8010 (or +61 2 6152 8010)
LinkedIn: http://www.linkedin.com/in/jevanpipitone
Facebook: http://www.facebook.com/jevanpipitone
GitHub: http://www.github.com/jevanpipitone
Twitter: http://www.twitter.com/jevanpipitone
Canberra, Australia


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.progclub.org/pipermail/programming/attachments/20190606/62e18291/attachment-0001.html>


More information about the programming mailing list