Date: Sat, 18 Feb 2023 17:09:21 -0500 From: Zaphod Beeblebrox <zbeeble@gmail.com> To: freebsd-hackers@freebsd.org Subject: Re: avoiding periodic(8) during long poudriere runs Message-ID: <CACpH0MdrKQyk4fMu--6VKVtH-z4g1XqAeP8j-skZqwfB3wDQZQ@mail.gmail.com> In-Reply-To: <Y/FJmq6Zx0Rgphdx@int21h> References: <Y/EE%2BWabwqiLifBx@int21h> <c64dd767-298d-c3a7-0cf6-cd7b8a58a656@quip.cz> <Y/FJmq6Zx0Rgphdx@int21h>
next in thread | previous in thread | raw e-mail | index | archive | help
--000000000000474aad05f500afc3 Content-Type: text/plain; charset="UTF-8" lockf(1) can be used at the beginning of a script: lockf -t 60 /tmp/mylockfile /root/bin/myscript and then when you're running poudriere, lockf /tmp/mylockfile poudriere <other args> On Sat, Feb 18, 2023 at 4:57 PM void <void@f-m.fm> wrote: > On Sat, Feb 18, 2023 at 09:46:43PM +0100, Miroslav Lachman wrote: > > >I don't know about any generic way, but you can put some shell code into > >/etc/periodic.conf to exit if load is too high > > > >Just a quick and dirty example, exit if 5 minutes avg is higher than 1.1: > > > >avg5load=$(top | awk '/load averages:/ { load=$7+0; if (load > 1.1) { > >print "HIGH" } }') > >echo $avg5load > >if [ "$avg5load" = "HIGH" ]; then > > echo "CPU load is too high" > > exit 5 > >fi > > Many thanks for this. I didn't know one could put scripting into > periodic.conf! > > -- > > --000000000000474aad05f500afc3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div>lockf(1) can be used at the beginning of a script:</d= iv><div><br></div><div>lockf -t 60 /tmp/mylockfile /root/bin/myscript<br></= div><div><br></div><div>and then when you're running poudriere,</div><d= iv><br></div><div>lockf /tmp/mylockfile poudriere <other args><br></d= iv></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_att= r">On Sat, Feb 18, 2023 at 4:57 PM void <<a href=3D"mailto:void@f-m.fm">= void@f-m.fm</a>> wrote:<br></div><blockquote class=3D"gmail_quote" style= =3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding= -left:1ex">On Sat, Feb 18, 2023 at 09:46:43PM +0100, Miroslav Lachman wrote= :<br> <br> >I don't know about any generic way, but you can put some shell code= into<br> >/etc/periodic.conf to exit if load is too high<br> ><br> >Just a quick and dirty example, exit if 5 minutes avg is higher than 1.= 1:<br> ><br> >avg5load=3D$(top | awk '/load averages:/ { load=3D$7+0; if (load &g= t; 1.1) {<br> >print "HIGH" } }')<br> >echo $avg5load<br> >if [ "$avg5load" =3D "HIGH" ]; then<br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0echo "CPU load is too high"= <br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0exit 5<br> >fi<br> <br> Many thanks for this. I didn't know one could put scripting into period= ic.conf!<br> <br> -- <br> <br> </blockquote></div> --000000000000474aad05f500afc3--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACpH0MdrKQyk4fMu--6VKVtH-z4g1XqAeP8j-skZqwfB3wDQZQ>