AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1047158
Accepted
user6493398
user6493398
Asked: 2020-12-23 01:05:56 +0800 CST2020-12-23 01:05:56 +0800 CST 2020-12-23 01:05:56 +0800 CST

如何设置 cron 作业以在官方 Redmine Docker 映像中发送提醒电子邮件?

  • 772

在基于Docker Hub上的官方图像的 Redmine 容器中,我正在尝试设置一个 cron 作业以定期发送提醒电子邮件。

按照此处的说明,在容器内键入bundle exec rake redmine:send_reminders RAILS_ENV=productionas可以正常工作。root但是,设置相同的命令 usingcrontab -e不起作用并输出各种错误消息。我怀疑它们与PATH为 Bundler 或 rake 设置正确有关,但不熟悉 Ruby 应用程序我现在完全迷路了。我什至尝试将(看似)相关的环境变量添加到crontab:

PATH=/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUBY_MAJOR=2.6
RUBY_VERSION=2.6.5
RUBY_DOWNLOAD_SHA256=d5d6da717fd48524596f9b78ac5a2eeb9691753da5c06923a6c31190abe01a62
GEM_HOME=/usr/local/bundle
BUNDLE_SILENCE_ROOT_WARNING=1
BUNDLE_APP_CONFIG=/usr/local/bundle
RAILS_ENV=production
HOME=/home/redmine
REDMINE_VERSION=4.1.0

但到目前为止无济于事。

以下是我crontab -e到目前为止尝试添加的内容。每个命令(当然)前面都是 cron 的日期时间字符串格式,后面是> /var/log/myjob.log 2>&1记录它输出的任何内容。

  • root cd /usr/src/redmine; bundle exec rake redmine:send_reminders RAILS_ENV=production
  • root cd /usr/src/redmine; /usr/local/bin/bundle exec /usr/local/bundle/bin/rake redmine:send_reminders RAILS_ENV=production

Could not locate Gemfile or .bundle/ directory

  • cd /usr/src/redmine; /usr/local/bin/bundle exec /usr/local/bundle/bin/rake redmine:send_reminders RAILS_ENV=production
  • /usr/src/redmine/remind.sh(以下脚本)

remind.sh

#!/bin/bash
cd /usr/src/redmine
bundle exec /usr/local/bundle/bin/rake redmine:send_reminders days=7 RAILS_ENV="production"
bundler: failed to load command: /usr/local/bundle/bin/rake
(/usr/local/bundle/bin/rake) Bundler::GemNotFound: Could not find
rake-13.0.1 in any of the sources  
/usr/local/lib/ruby/2.6.0/bundler/spec_set.rb:91:in `block in
materialize'   /usr/local/lib/ruby/2.6.0/bundler/spec_set.rb:85:in
`map!'   /usr/local/lib/ruby/2.6.0/bundler/spec_set.rb:85:in
`materialize'   /usr/local/lib/ruby/2.6.0/bundler/definition.rb:170:in
`specs'   /usr/local/lib/ruby/2.6.0/bundler/definition.rb:237:in
`specs_for'   /usr/local/lib/ruby/2.6.0/bundler/definition.rb:226:in
`requested_specs'  
/usr/local/lib/ruby/2.6.0/bundler/runtime.rb:108:in `block in
definition_method'  
/usr/local/lib/ruby/2.6.0/bundler/runtime.rb:20:in `setup'  
/usr/local/lib/ruby/2.6.0/bundler.rb:107:in `setup'  
/usr/local/lib/ruby/2.6.0/bundler/setup.rb:20:in `<top (required)>'  
/usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in
`require'  
/usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in
`require'
  • root cd /usr/local/bundle/bin/rake; rake --trace redmine:send_reminders RAILS_ENV=production
rake aborted! No Rakefile found (looking for: rakefile, Rakefile,
rakefile.rb, Rakefile.rb)
/usr/local/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:698:in
`raw_load_rakefile'
/usr/local/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:104:in
`block in load_rakefile'
/usr/local/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:186:in
`standard_exception_handling'
/usr/local/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:103:in
`load_rakefile'
/usr/local/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:82:in
`block in run'
/usr/local/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:186:in
`standard_exception_handling'
/usr/local/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/application.rb:80:in
`run' /usr/local/lib/ruby/gems/2.6.0/gems/rake-12.3.2/exe/rake:27:in
`<top (required)>' /usr/local/bundle/bin/rake:23:in `load'
/usr/local/bundle/bin/rake:23:in `<main>'

这是里面的东西/usr/src/redmine。存在一个名为的文件Gemfile。

root@975094a2b06b:/usr/src/redmine# ls -l
total 140
-rw-rw-r--  1 redmine redmine  538 Dec 20  2019 CONTRIBUTING.md
-rw-rw-r--  1 redmine redmine 2937 Dec 20  2019 Gemfile
-rw-rw-rw-  1 redmine redmine 5665 Apr 21  2020 Gemfile.lock
-rw-r--r--  1 root    root    5491 Feb 27  2020 Gemfile.lock.mysql2
-rw-r--r--  1 root    root    5483 Feb 27  2020 Gemfile.lock.postgresql
-rw-r--r--  1 root    root    5493 Feb 27  2020 Gemfile.lock.sqlite3
-rw-r--r--  1 root    root    5645 Feb 27  2020 Gemfile.lock.sqlserver
-rw-rw-r--  1 redmine redmine  205 Dec 20  2019 README.rdoc
-rwxrwxr-x  1 redmine redmine  275 Dec 20  2019 Rakefile
drwxrwxr-x  6 redmine redmine 4096 Dec 20  2019 app
-rw-rw-r--  1 redmine redmine  863 Dec 20  2019 appveyor.yml
drwxrwxr-x  2 redmine redmine 4096 Dec 20  2019 bin
drwxr-xr-x  1 redmine redmine 4096 Mar 26  2020 config
-rw-r--r--  1 root    root     136 Mar 10  2020 config.ru
drwxrwxrwx  1 redmine redmine 4096 Mar 26  2020 db
drwxrwxr-x  2 redmine redmine 4096 Dec 20  2019 doc
drwxrwxr-x  5 redmine redmine 4096 Dec 20  2019 extra
drwxr-xr-x  3 redmine redmine 4096 Oct 19 10:16 files
drwxrwxr-x  6 redmine redmine 4096 Dec 20  2019 lib
drwxr-xr-x  2 redmine redmine 4096 Mar 18  2020 log
drwxr-xr-x  5 redmine redmine 4096 Mar 26  2020 plugins
drwxrwxr-x  1 redmine redmine 4096 Dec 20  2019 public
-rwxr-xr-x  1 root    root     125 Dec 17 16:24 remind.sh
drwxrwxrwx  2 redmine redmine 4096 Feb 27  2020 sqlite
drwxrwxr-x 14 redmine redmine 4096 Dec 20  2019 test
drwxr-xr-x  1 redmine redmine 4096 Feb 27  2020 tmp
drwxrwxr-x  2 redmine redmine 4096 Dec 20  2019 vendor

什么是正确的命令?

cron redmine docker
  • 1 1 个回答
  • 388 Views

1 个回答

  • Voted
  1. Best Answer
    user6493398
    2021-01-07T18:29:38+08:002021-01-07T18:29:38+08:00

    事实证明,BusyBox中包含的crond可以毫无问题地运行命令。也许它处理环境变量的方式与标准 crond 不同?bundle exec rake...

    我所要做的就是

    apt-get install busybox-static
    busybox crontab -e
    

    然后将以下作业添加到 crontab 的列表中。

    0 7 * * 1-5 cd /usr/src/redmine; bundle exec rake redmine:send_reminders RAILS_ENV=production
    

    请注意,目前,这些步骤是在运行的 Redmine 容器中手动完成的。我稍后会添加这些Dockerfile。

    • 0

相关问题

  • 每 4 小时运行一次 cron 的正确语法是什么?[复制]

  • 用于 mysql 数据库清理和备份的 crontab

  • Windows cron 作业

  • 使用 crontab 和 /etc/cron.hourly,daily,weekly 的区别

  • crontab ifconfig 什么都不输出

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve