Announcement

Collapse
No announcement yet.

crontab mystery

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    crontab mystery

    Kubuntu 20.04 on several PCs

    On all PCs, when I execute
    /usr/bin/aplay -P "/home/username/Bells/SteelBell-C5.wav"
    it works correctly and plays the file which produces a nice audio tone.

    When I place the same command in my crontab file,
    it works on some PCs but not on all PC's ?

    Syslog shows the following on both working and non-working PCs.
    (CRON) info (No MTA installed, discarding output)

    I have no idea what MTA is and no idea why it works on some PC's and not on all PC's.

    #2
    I guess mail transfer agent? a cron job wants to email output of what it runs. Maybe redirecting output somewhere useful would see errors that aplay makes, by appending "> /home/username/aplay_cron.log 2>&1".
    Regards, John Little

    Comment


      #3
      Contents of aplay_cron.log file is :

      ALSA lib pcm_dmix.c:1089snd_pcm_dmix_open) unable to open slave
      aplay: main:830:audio open error:no such file or directory

      Any ideas of what it is missing ?
      Last edited by Snowhog; Sep 12, 2020, 06:54 PM.

      Comment


        #4
        Only to check that your user is in the "audio" group. In a konsole, run groups. If not,
        Code:
        sudo usermod -a -G audio $USER
        is a way to do so. (idk why it was taken out of system settings).

        Or, another idea, use pulse audio:
        Code:
        XDG_RUNTIME_DIR=/run/user/1000 /usr/bin/paplay ...
        but that will only work if you're logged in at the time.

        More generally, cron is an ancient mechanism, and has lots of gotchas. systemd timers might be an idea, but I haven't tried that. There's lots of projects some with incredible feature sets, but it's years since I used one.
        Regards, John Little

        Comment


          #5
          Thanks for the suggestions.
          Both aplay and paplay work from the command line, and neither works when in crontab on some PC's.
          Beats me why

          Comment


            #6
            step 1

            Code:
            xuser@mbs:~$ env|grep -i runt
              XDG_RUNTIME_DIR=/run/user/1000
            step 2 create file play.sh (remember about chmod)

            Code:
            #!/bin/bash
              export XDG_RUNTIME_DIR=/run/user/1000
              /usr/bin/mpg123 $1
            step 3 `crontab -e`

            Code:
            хх * * * * /home/xuser/bin/play.sh /home/xuser/Музыка/demo_moya_vesna.mp3
            step 4

            $%)) ata-ta % enjoy

            Comment

            Working...
            X