Script works, but very slow

Good evening,

I put together a script that opens the CD tray, plays a .wav file, and then closes the tray. It does so every hour, as many times as the current number of hours. However, after every cycle, there seems to be a large slow-down. What could this be linked to? Is there any way to debug it?


KUKU=`/bin/date +%H` # Get the current hour
KUKU=$((10#$KUKU)) # Convert it to decimal, in case it is 01, etc.
if  $KUKU -gt 12 ]; then # Convert to a 12 hour clock.
elif  $KUKU -eq 0 ]; then # Midnight
KUKU=12 # Same amount as at noon
while  $KUKU -gt 0 ]; do
eject /dev/cdrom
aplay /mnt/storage/Music/kuku.wav # The file - plays successfully
eject -t /dev/cdrom
KUKU=$((KUKU-1)) # Decrement

I have added comments now, but they are not in the main file, and so it cannot be caused by them - except the #!/bin/bash comment, but that is required.

By adding “echo step” after each value, it seems that it takes a long time for the CD tray to be retrieved - far longer than it physically does. Any ideas?

Thank you,

I think I found the problem - the tray automounts upon closing. Is there any way to disable automounting from the console? The script is run by cron, and thus as root. Preferably, I would like nothing at all to be done with it - meaning that the computer shouldn’t even try to identify the format of the CD. Any ideas?

Thank you,