L
L
LoliDeveloper2021-07-24 21:21:49
linux
LoliDeveloper, 2021-07-24 21:21:49

How to play files from bash script?

I made such a script for reminders, and placed it in crontab.

#!/bin/bash
...
/usr/bin/RHVoice-client -v 1 -s Anna+CLB < /tmp/text.txt | aplay


#крон
* * * * * /home/usrname/dir/sh1 > /tmp/sh1.log 2>&1


If you run it from the command line, then everything is OK , but if the cron itself launches it, then aplay swears:
ALSA lib pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave
aplay: main:852: audio open error: Device or resource busy

Can something be done about it? Or is it even worth trying to solve this problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
LoliDeveloper, 2021-07-24
@LoliDeveloper

Oh my god I solved it.
It is necessary to crontab -eadd in the XDG_RUNTIME_DIR=/run/user/$(id -u)script before the script.
I ran:
* * * * * /home/usr/dir/sh1 > /tmp/sh1.log 2>&1
And it is necessary:

* * * * * XDG_RUNTIME_DIR=/run/user/$(id -u) /home/usr/dir/sh1 > /tmp/sh1.log 2>&1

K
ky0, 2021-07-24
@ky0

Standard set of checks:
1. The user from under which it is launched.
2. Shell used, environment variables, absolute paths.
3. The directory in which it is executed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question