Post-triggered recording

[Audacity 2.2.2 on Debian buster. installed from the repositories.]

Hi experts here,
I wonder if you could give me an advice or if Audacity is the right track to start with:

I need to record events (ideally with a timestamp) that happen randomly and I am only able to detect it even once it has happened.
The given solution should be able to automatically record approximately 1 min. before the threshold and a programmable time after it.
(digital oscilloscopes are working that way)

Can Audacity give some help for my case?
Thank you for any hint that could put me on track…

Audacity is not suitable for that. There is no way with Audacity, to do that.
You need a “surveillance recorder” of some kind.

I’m not aware of any such app for Linux, though I guess that it would be possible to write a script (for example, with bash or Python), to record short audio files, then automatically delete the file if the peak amplitude is below a certain threshold.

I thought about using a preceding delay line by 1 min and then to trigger recording by Audacity.
Something like that: https://github.com/stevenryoung/RadioDelay
Is it possible to trigger a recording of about 2 min right from the command line?

Something like:

arecord -f cd -d 120 out.wav

(see: https://linux.die.net/man/1/arecord)

or to use PulseAudio, use parec or parecord (see: parec(1) — pulseaudio-utils — Debian testing — Debian Manpages)

Thank you Steve, I will dig into that.
I suppose I will need Jack as well in order to insert the delay without blocking the sound port and some kind of threshold detector…