I have been at this for a month now. New to programming. Trying to run a schedule for wav files to execute. Using Raspberry Pi 3 and Raspbian Stretch. My cron.d file called 'BellCron' is as follows:
/5 * * * * pi /home/pi/CronJobs/BellsCron.sh
Applied chmod +x to the BellsCron.sh file.
It is a file that executes a second file, 'playAngelus.py'. When I execute 'BellsCron.sh' at the command line it works fine.
The 'BellsCron.sh file looks like this:
#!/usr/bin/env python sudo -u pi python /home/pi/CronJobs/playAngelus.py
The 'playAngelus.py' file looks like this:
#!/user/bin/env python import pygame import time pygame.init() pygame.mixer.music.load("/home/pi/Music/Angelus.wav") pygame.mixer.music.play() time.sleep(10)
I have also run a text file from the same cron.d file that is giving me the time in a file every 2 minutes, so I know it is running cron. But, the sound file will not work using cron. I accept that the error is mine. I have tried every configuration I can find on the web. I would be most appreciative if someone would help me to write the script I need to execute a wav file in my home directory, /home/pi/Music/Angelus.wav, using cron.d or crontab.
sudo -u pi …, as that's just reverting your cron job back to the default Raspbian user.