How to make Linux `speaker-test` happen only for a given duration?
Aug 7, 9:56pm

To make the speaker-test command in Linux run for a specific duration, you can use the timeout command to automatically stop the test after the desired time. Here’s how you can do it:

Command:

bash
timeout <duration_in_seconds> speaker-test <options>

Example:

If you want to run speaker-test for 10 seconds, use:

bash
timeout 10s speaker-test -c 2
  • -c 2 specifies the number of channels (e.g., stereo).
  • 10s sets the duration to 10 seconds.

How It Works:

  • The timeout command will terminate the speaker-test process after the specified duration.
  • Replace <duration_in_seconds> with your desired time (e.g., 5s, 30s, etc.).
  • Add any additional speaker-test options (e.g., -t wav for WAV file playback, -D <device> for a specific sound card).

Notes:

  • If timeout is not available, ensure it’s installed (it’s part of GNU Coreutils and is usually pre-installed on most Linux distributions).
  • Pressing Ctrl+C will also stop the test manually.
Aug 7, 9:56pm

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Vibe can make mistakes. Check answers. Learn more