How do you normally handle empty files created by MixMonitor(b)?

How do you normally handle empty files created by MixMonitor(b)?

When using:

MixMonitor(filename.wav,b)

Asterisk creates the recording file immediately, even if the channel is never bridged.

The b option prevents audio from being written until the channel is bridged, but calls that hang up in an IVR before any bridge still leave behind an empty/header-only WAV file.

On a high-volume system this can result in thousands of empty recording files, which then have to be handled by storage/upload processes.

How do regular production Asterisk systems normally deal with this?

Do you usually:

  • ignore/delete empty recordings afterward,

  • only start MixMonitor later in the call flow,

  • or handle this some other way?

Use the /tmp/ dir and let “Linux do its magic”. For other systems where we have files we want to clean out we have a script (via cron) that looks at the last time the file was modified. If it’s empty we remove it.

/tmp only gets purged on a reboot, and the OP wouldn’t want the completely directory discarded.

Also, if they are using .wav files, empty means 44 bytes, which is not something you can easily test with find.

thanks

set up a cron job that checks the recording files. If a file is no longer open/in use by Asterisk and is only 44 bytes (WAV header only), it can be treated as an empty recording and removed.

MixMonitor() accepts a command argument that will execute when the monitor ends.

Challenge accepted!

sudo find /archive/\
	-empty\
	-o\
	-size 44c\
	-mtime +7\
	-ls