It does not matter which instruction related to sound I use. It seems that instruction is working, but I hear no sound. Crontab run on the same user and on root. No sound effect (process works in the back).

  1. espeak -ven "Hello" - typed in a terminal works, typed in a cron does not. In htop I see that espeak is working every minute.
  2. amixer -D pulse sset Master 10% - in a terminal works, typed in a cron does not.
  3. mpsyt .blablabla, 1 - in a terminal works, typed in a cron does not.
  4. Google Assistant started normally works. Started from cron does not (do not even hear me - so mic problem is also an issue).

Logs are empty except mpsyt log saying: "]2;mpsyt" whatever it means :).

Cronjobs not related to sound work perfectly. I made a script that writes to file and play a sound. File is fine. No sound at all.

I was always sure that running scripts from cron are equal to scripts run from terminal. So what causes the difference?


  • The difference is that cron scripts are run as root.
    – Pilot6
    Jun 10, 2018 at 11:24
  • At my computer it does not take any difference. Running the same script as my cronjob or root cronjob. No sound at all. Running the same script in a teminal either as root or me gives me sound.
    – phoenix84
    Jun 10, 2018 at 11:25
  • 2
    Cron is not the same as terminal. Cron has no idea about consolekit or most other environment variables, so it has no idea where to send audio or video or display. You must specify those environment variables.
    – user535733
    Jun 10, 2018 at 12:34

3 Answers 3


As per this answer: Can I use cron to chime at top of hour like a grandfather clock? you need to export an environment variable before playing sounds in your cron script:

export XDG_RUNTIME_DIR="/run/user/1000"
  • Thx for this answer. After reinstall voice came back to my cron, but still sometimes disappears. I do not see any reason or algorithm when it works and when not. Now >99% works. When I see it is not working, I will check that solution. K.
    – phoenix84
    Jun 20, 2018 at 22:58
  • This.. This helped. Thank you @WinEunuuchs2Unix
    – nohup
    Jun 24, 2019 at 18:17

Thx for trying to help. I have just done a complete reinstall of Ubuntu 18.04 (too many issues without installation done with few upgrades).



You may need to initialize sound in crontab temporary shell to get sound.

So you can initialize sound in crontab or at least in script that is called from crontab.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.