I have a python script called backupapp.py
import subprocess, time
from datetime import date
app_name = 'xxxxx'
capture_backup = subprocess.check_output(['heroku','pg:backups:capture','--app',app_name]) # Make a new backup
time.sleep(5)
info_backup = subprocess.check_output(['heroku','pg:backups:info','--app',app_name])
name_backup = info_backup[11:15] # Extract the name of the backup database
today = date.today().strftime("%m_%d_%Y")
filename = name_backup + '_' + today + '.dump'
url = subprocess.check_output(['heroku','pg:backups:url', name_backup,'--app',app_name])
url = url[:-1] # Remove \n from the string
print "Beginning Download....."
download_backup = subprocess.check_output(['curl', '-o', filename, url])
This script works when I run it in the terminal python backupapp.py
However, I want to run this everyday at noon.
So I used crontab -e and added this:
0 12 * * * cd /Users/myuser/Desktop/Work/appbackup && python backupapp.py
But this isn't running. I checked for some answers online to see the logs, but the logs do not exist.
cd, just directlypython /Users/myuser/Desktop/Work/appbackup/backupapp.py?/path/to/python /Users/myuser/Desktop/Work/appbackup/backupapp.pyorcd /Users/myuser/Desktop/Work/appbackup && /path/to/python backupapp.py