Reputation: 2838
I run these three commands everyday:
cd /Users/xxx/code
heroku pgbackups:capture --expire
curl -o latest.dump `heroku pgbackups:url`
So I thought I'd try to move it into a cron job so I created a file called /Users/xxx/code/backup_script that has the following:
cd /Users/xxx/code
heroku pgbackups:capture --expire
curl -o latest.dump `heroku pgbackups:url`
However, when I run ./backup_script it gives this error:
./backup_script
./backup_script: line 2: heroku: command not found
./backup_script: line 3: heroku: command not found
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
I'm a unix newbie - can someone help me figure out how to fix the script above?
Upvotes: 0
Views: 363
Reputation: 7752
Try adding a shebang telling it to use the bourne again shell (bash):
#!/bin/bash
cd /Users/xxx/code
heroku pgbackups:capture --expire
curl -o latest.dump `heroku pgbackups:url`
A full path to heroku might help.
If you don't have luck here, you could also try the Unix/Linux stack exchange site:
Upvotes: 0
Reputation: 12339
The environment variables for a cronjob are significantly reduced from your login; you'll want to set $PATH for your crontab.
For instance:
PATH=$HOME/bin:$PATH
@daily $HOME/backup_script
You may want to run which heroku
to figure out what path you need to add.
Upvotes: 4