开发者

How to create a system generated alert tone in linux , without using any external audio file?

I have a linux shell script , which i need to run at every 30 min interval, so i'm using a infinite for loop like this:

for ((i=0;;i++))
do
clear;
./myscript.sh;
sleep 30m;
done

i want to add a line of code before clear , so tha开发者_JAVA技巧t before the script executes everytime,system generates an alert tone or sound , which will make the user aware that 30 min interval has passed by and the script is executing again.Any way to do that?

I currently dont have any external .wav file in my system which can be played as an alert. kindly suggest.


For a simple tone you can use beep command. You can find this command in debian repositories, the package name is beep.

It is a simple script and you can use it in commandline.


you can emit a BEL character (char code 7, ^G) to /dev/console. Beware that only root is allowed to do so.

With proper escape codes, you can even control the length and frequency of a beep.

For example, the code below constitutes, run in a cron job, a cuckoo clock :-)

#!/bin/sh
h=$(((`date +%k`+11)%12+1))
echo -en "\033[11;200]" >/dev/console
for ((i=0; i<h; i++)); do
        echo -en "\033[10;600]\a"
        usleep 200000
        echo -en "\033[10;490]\a"
        usleep 500000
done >/dev/console
echo -en "\033[10;750]\033[11;100]" >/dev/console
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜