I am new to scheduling tasks with crontab. I am trying to open python script as if I open player and play some song. Programm work well alone, but with crontab its did not work. my crontab task
*/5 * * * * cd /home/jack/projects/auto_stuff/18 && /usr/bin/python3.6 torrent_control.py
my code for open player and play song
with open('song.txt', 'a') as f:
try:
if player == 'play':
subprocess.Popen(['/usr/bin/deadbeef', 'song.mp3'])
except Exception:
traceback.print_exc(file=f)
I know before subprocess code works right. I seen advice absolute path in "subprocess.Popen", but its already absolute or Im wrong? I try to log my outputs to a file and script does not show any exceptions. I change crontab task
*/5 * * * * /usr/bin/python3.6 /home/jack/projects/auto_stuff/18/torrent_control.py
And I change script code:
with open('/home/jack/projects/auto_stuff/18/song.txt', 'a') as f:
try:
if player == 'play':
subprocess.Popen(['/usr/bin/deadbeef', '/home/jack/projects/auto_stuff/18/song.mp3'])
f.write(' Done.\n')
except Exception:
traceback.print_exc(file=f)
print('Not done', file=f)
in song.txt output always 'Done.'