无法让 cron 脚本工作
我每天运行这三个命令:
cd /Users/xxx/code
heroku pgbackups:capture --expire
curl -o latest.dump `heroku pgbackups:url`
所以我想我应该尝试将它移动到 cron 作业中,所以我创建了一个名为 /Users/xxx/code/backup_script 的文件,其中包含以下内容:
cd /Users/xxx/code
heroku pgbackups:capture --expire
curl -o latest.dump `heroku pgbackups:url`
但是,当我运行 ./backup_script 时,它给出这个错误:
./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
我是一个 unix 新手 - 有人可以帮我弄清楚如何修复上面的脚本吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
登录后,cronjob 的环境变量会显着减少;你需要为你的 crontab 设置 $PATH。
例如:
您可能需要运行
which heroku
来找出需要添加的路径。The environment variables for a cronjob are significantly reduced from your login; you'll want to set $PATH for your crontab.
For instance:
You may want to run
which heroku
to figure out what path you need to add.尝试添加一个 shebang 告诉它再次使用 bourne shell (bash):
heroku 的完整路径可能会有所帮助。
如果你在这里运气不好,你也可以尝试 Unix/Linux 堆栈交换站点:
Try adding a shebang telling it to use the bourne again shell (bash):
A full path to heroku might help.
If you don't have luck here, you could also try the Unix/Linux stack exchange site: