Re: Cron para alarma diaria.
El 2024-09-11 a las 19:35 +0200, Diego Bote escribió:
> Buenas tardes.
> Pues sigue abierto el asunto, porque ya funciona correctamente cuando estoy
> dentro del sistema, esto es, he hecho login, pero no cuando no estoy dentro
> del sistema, pues me lanza este error.
Eso se debe a que la variable de entorno que has definido en la tarea
de crontab se define cuando has iniciado una sesión gráfica («XDG_»).
^
Al no haber iniciado sesión, el problema originario ha vuelto.
> Failed to create secure directory (/run/user/1000/pulse): No such file or
> directory
> ...
> SDL_OpenAudio (2 channels, 48000 Hz): ALSA: Couldn't open audio device: Host is down
> SDL_OpenAudio (1 channels, 48000 Hz): ALSA: Couldn't open audio device: Host is down
> SDL_OpenAudio (2 channels, 44100 Hz): ALSA: Couldn't open audio device: Host is down
> SDL_OpenAudio (1 channels, 44100 Hz): ALSA: Couldn't open audio device: Host is down
> No more combinations to try, audio open failed
> Failed to open file '/home/diego/parler-du-programme-de-julie.mp3' or configure filtergraph
> el ejecutar la línea de cron
> 11 19 * * * XDG_RUNTIME_DIR=/run/user/$(id -u) /usr/bin/ffplay -t 20 -nodisp -autoexit /home/diego/musica.mp3
> ¿Alguna ayuda?
Pues tendrás que ver la forma de que Pulsaudio se inicie sin hacer
«login» (p. ej., se me ocurre ejecutarlo en modo servidor, pero quizá
sea excesivo y cargue muhco el sistema).
También puedes probar la alterniva que comentan en la wiki de Archlinux
(«machinectl»):
****
9.2 Play sound from a non-interactive shell (systemd service, cron)
https://wiki.archlinux.org/title/PulseAudio#Play_sound_from_a_non-interactive_shell_(systemd_service,_cron)
Set XDG_RUNTIME_DIR before the command (replace user_id with the ID of
the user running PulseAudio):
$ XDG_RUNTIME_DIR=/run/user/user_id paplay /usr/share/sounds/freedesktop/stereo/complete.oga
Or use machinectl:
# machinectl shell .host --uid=user_id /usr/bin/paplay /usr/share/sounds/freedesktop/stereo/complete.oga
****
O «pasar» (omitir) completamente de Pulseaudio (alternativas: Jackd,
PipeWire, ALSA...) :-)
Saludos,
--
Camaleón
Reply to: