Crontab as alarm clock with ogg123

Cameron Simpson cs at
Sat Jul 24 23:34:54 UTC 2010

On 24Jul2010 12:55, Robert Arkiletian <robark at> wrote:
| Using 'crontab -e' I set crond to play an ogg music file with ogg123.
| But it only plays it if I'm logged in.
| How does one make it play even if a different user is logged in or
| nobody is logged in?

Can you show us exactly what command you used?

A lot of desktops change the file permissions of "core"/"console"
devices at login to make them owned by the logged in user, so that
other people remotely (or cronly) using the machine can't muck about
with their desktop. (And their sound.)

| To debug I tried su - to another user and play the file. I got error

Try "su -" to be root, not another non-root user. Would be interesting
to see what happens.

| ALSA lib pulse.c:229:(pulse_connect) PulseAudio: Unable to connect:
| Connection refused

Maybe opening a unix socket it doesn't own?

  strace -f -e trace=file 2>/tmp/str.out ogg123 ...ogg-args...

then look at str.out. It will show you exactly what devices/files it
tries to open and whether the opens work.

| === Could not load default driver and no driver specified in config
| file. Exiting.

Probably a side effect of the failed open - this isn't lack of drivers,
it is lack of access.

| So I'm thinking it's the same infrastructure to prevent others music
| playing when you switch users.


| But in my case I *want* it to play. Any
| ideas?

Sudo? Grant your user the right to use ogg123 as root without a password
and without needing a terminal (because it's happening from cron).

Might I suggest the "at" command instead of cron? The same access issues
will apply but you can more easily queue commands for arbitrary times.

Cameron Simpson <cs at> DoD#743

Pigface is our blunt trauma. The 2x4 of pure reason, the baseball bat
of higher logic, the lead pipe of rationality.  - Ken Strayhorn

More information about the users mailing list