'Python 3.9.7 script failing to run on ubuntu crontab
I am currently attempting to setup a raspberry pi 4 as an intercom system using ubuntu 21.10. I am using functioning python scripts to play mp3s via cron jobs.
My scripts are almost exactly the same as this except for differing mp3 files:
#!/usr/bin/env python3
from pygame import mixer
from pygame import time
mixer.init(frequency=90000, size=-16, channels=2, buffer=512)
mixer.music.load("/home/intercompi/Music/0min-closing.mp3")
mixer.music.set_volume(0.7)
mixer.music.play()
while mixer.music.get_busy():
time.Clock().tick(10)
quit()
My crontab is as follows:
30 20 * * 1-4 /home/intercompi/30min-closing.py >> IntercomOutput.txt 2>&1
45 20 * * 1-4 /home/intercompi/15min-closing.py >> IntercomOutput.txt 2>&1
55 20 * * 1-4 /home/intercompi/5min-closing.py >> IntercomOutput.txt 2>&1
0 21 * * 1-4 /home/intercompi/0min-closing.py >> IntercomOutput.txt 2>&1
30 17 * * 0,5,6 /home/intercompi/30min-closing.py >> IntercomOutput.txt 2>&1
45 17 * * 0,5,6 /home/intercompi/15min-closing.py >> IntercomOutput.txt 2>&1
55 17 * * 0,5,6 /home/intercompi/5min-closing.py >> IntercomOutput.txt 2>&1
0 18 * * 0,5,6 /home/intercompi/0min-closing.py >> IntercomOutput.txt 2>&1
and my logging file outputs this:
/bin/sh: 1: usr/bin/python3: not found
/bin/sh: 1: usr/bin/python3: not found
/bin/sh: 1: usr/bin/python3: not found
I am fairly inexperienced with linux so I apologize if this is sloppy. This is partly a consolidation of my previous attempts at looking into this issue.
Solution 1:[1]
Does "/usr/bin/env python3" on command line navigates you to python console ?
you can also use the output of the "which" command in your script.
which python3
for instance
#!/usr/bin/python3
from pygame import mixer
from pygame import time
mixer.init(frequency=90000, size=-16, channels=2, buffer=512)
mixer.music.load("/home/intercompi/Music/0min-closing.mp3")
mixer.music.set_volume(0.7)
mixer.music.play()
while mixer.music.get_busy():
time.Clock().tick(10)
quit()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Hamed Maaleki |
