DEf*_*ion 8 ubuntu shell bash cron
这是我的 crontab 文件的内容:
0 0,6,12,18 * * * cd /var/www/app/current && backup perform --trigger db_backup --config_file config/backup.rb --data-path db --log-path log --tmp-path tmp >> /var/www/app/current/log/cron.log 2>&1
0 3 * * * cd /var/www/app/current && RAILS_ENV=production bundle exec rake runs:populate --silent >> /var/www/app/current/log/cron.log 2>&1
59 23 * * * cd /var/www/app/current && RAILS_ENV=production bundle exec rake runs:log --silent >> /var/www/app/current/log/cron.log 2>&1
Run Code Online (Sandbox Code Playgroud)
如果我以 crontab 的所有者身份手动运行其中任何一个,它们工作正常,但该cron.log
文件仅包含:
/bin/sh: bundle: not found
/bin/sh: backup: not found
/bin/sh: bundle: not found
Run Code Online (Sandbox Code Playgroud)
我尝试将每一个都包装在以下(默认情况下,我用来管理我的 cron 文件的每当 gem 的默认值)bash -l -c '...'
但是我得到了与上面相同的除了 bashbash: bundle: command not found
use*_*517 13
CRON 作业的默认路径通常是/usr/bin:/bin
. 你的命令bundle
,并backup
很可能不是在默认路径。一种解决方案是更改您的 crontab 并包含这些命令的完整路径。
0 0,6,12,18 * * * cd /var/www/app/current && /path/to/backup ...
Run Code Online (Sandbox Code Playgroud)
等等。一般来说,在 crontab 中使用完整路径是个好主意。如果需要,您还可以在 crontab 中指定 PTH
PATH=/bin:/usr/bin:/path/to/your/program
0 0,6,12,18 * * * cd /var/www/app/current && backup ...
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5844 次 |
最近记录: |