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

John Elliot V | ProgClub jj5 at progclub.org
Thu Jun 6 12:53:29 AEST 2019


Hi Raz,

I have applied your patch:

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

On 6/6/19 12:42 pm, Roland Turner via programming wrote:
> That said, if your maintenance automation scripts aren't using -e, then
> this may help explain your reliability anxiety.

Oh. Before I knew of -e (which I enable by default:

https://svn.jj5.net/jjrepo/jj5-bin/branches/0.2/bin/new-sh.sh?revision=2418#l154

now that I know about it, although I do find myself removing it from
time to time), I created run():

https://svn.jj5.net/jjrepo/jj5-bin/branches/0.2/bin/inc/lib.sh?revision=2412#l1162

to check the output and fail on non-zero return. So in my scripts if I
want to automatically bail on error I just prefix my commands with
'run', e.g.

 quiet pushd /tmp
 run mkdir whatever
 run rmdir whatever
 quiet popd

Note: quiet() is like run(), in that it handles errors, but it
suppresses output on stdout and doesn't report the job its running.
There's silent() too, which is like quiet(), but which suppresses output
on stdout and stderr.

> This would be obviated if bash could be persuaded to take an exclusive
> lock on a file, which means that no cleanup would be required: the lock
> would open automatically when the process terminated. I don't know of
> any way to get bash to do this.

 $ man flock .. ?

May the Force be with you,
John Elliot V
-- 
|_|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/5b74100d/attachment.vcf>


More information about the programming mailing list