[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:10:01 AEST 2019


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


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


More information about the programming mailing list