0

I have a script that executes perfectly fine manually, though two commands in particular are completely ignored by Cron (this is just a snippet):

sinkint=$(pacmd list-sinks | sed -n '/index\W [1-9]/p' | sed 's/.*://g;s/\W//g')

pacmd set-default sink $sinkint
pacmd set-sink-volume $sinkint 20%

I have a feeling it has something to do with the builtin function "set", so I've tried adding a path and using "env pacmd..." for both of the commands, though no luck. I've also tried "$(pacmd...)", as well as disabling the builtin with "enable -n set" - also tried setting the interpreter to sh instead of bash.

Any help on this would be greatly appreciated, I'm completely lost.

Edit: crontab

* * * * * /path/to/script arg1 >> /path/to/log

Edit: error messages

No PulseAudio daemon running, or not running as session daemon.
No PulseAudio daemon running, or not running as session daemon.
You have to specify a sink name/index and a volume
18
  • 1
    You're not using the built-in command set anywhere. Commented Sep 13, 2021 at 15:03
  • 1
    Your .bashrc and .profile aren't executed from cron. If you add the directory containing pacmd to your $PATH there, it won't be available in cron. Use the absolute path of the command. Commented Sep 13, 2021 at 15:04
  • might have been wise to show my crontab ` PATH=$PATH:/usr/bin * * * * * /path/to/script 1starg >> /path/to/log ` something like this Commented Sep 13, 2021 at 15:21
  • 1
    /usr/bin is normally in the default PATH, you shouldn't need to add it. Commented Sep 13, 2021 at 15:26
  • 1
    Does this answer your question? Bash Script works but not in when executed from crontab And many many many more with the same question, crontab questions like this occur almost once a day. Commented Sep 13, 2021 at 17:26

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.