簡體   English   中英

每當工作時都無法獲取Ruby

[英]Can't get Ruby Whenever working

whenever我在本地開發環境中工作時,我whenever遇到一些麻煩。 我正在使用mac OS 10.12ruby 2.4rails 5.1以及whenever 0.10.0

我將schedule.rb文件設置為:

set :environment, "development"
set :job_template, "TZ=\"America/Los_Angeles\" bash -l -c ':job'"
set :output, Whenever.path + "/log/cron.log"

every 5.minutes do
  runner "Test.new.run"
  command "/bin/echo 'Is this working?'"
end

crontab -l輸出以下內容:

# Begin Whenever generated tasks for: /Users/me/apps/Test/config/schedule.rb at: 2018-05-25 12:59:14 -0700
0,5,10,15,20,25,30,35,40,45,50,55 * * * * TZ="America/Los_Angeles" bash -l -c 'cd /Users/me/apps/Test && bundle exec bin/rails runner -e development '\''Test.new.run'\'' >> /Users/me/apps/Test/log/cron.log 2>&1'

0,5,10,15,20,25,30,35,40,45,50,55 * * * * TZ="America/Los_Angeles" bash -l -c '/bin/echo '\''Is this working?'\'' >> /Users/me/apps/Test/log/cron.log 2>&1'


# End Whenever generated tasks for: /Users/me/apps/Test/config/schedule.rb at: 2018-05-25 12:59:14 -0700

並且在終端中運行mail命令時收到以下消息:

  Message 1:
From me@box.local  Fri May 25 13:00:01 2018
X-Original-To: me
Delivered-To: me@box.local
From: me@box.local (Cron Daemon)
To: me@box.local
Subject: Cron <me@box> TZ="America/Los_Angeles" bash -l -c '/bin/echo '\''Is this working?'\'' >> /Users/me/apps/Test/log/cron.log 2>&1'
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=me>
X-Cron-Env: <USER=me>
X-Cron-Env: <HOME=/Users/me>
Date: Fri, 25 May 2018 13:00:00 -0700 (PDT)

但是,我看不到cron.log任何輸出, cron.log也沒有反映出Test.new.run任何活動

不太確定我在做什么錯...

我認為問題可能與rvm和我設置的.rvmrc文件有關,當我將cd插入目錄時,該文件會加載正確的rvm設置。

為了確保命令正常工作,打開了一個新的終端窗口並運行: bash -l -c 'cd /Users/me/apps/Test && bundle exec bin/rails runner -e development '\\''Test.new.run'\\'' >> /Users/me/apps/Test/log/cron.log 2>&1'

首先出現的是標准的1 off rvm消息:

You are using '.rvmrc', it requires trusting, it is slower and it is not compatible with other ruby managers,
you can switch to '.ruby-version' using 'rvm rvmrc to ruby-version'
or ignore this warning with 'rvm rvmrc warning ignore /Users/me/apps/Test/.rvmrc',
'.rvmrc' will continue to be the default project file in RVM 1 and RVM 2,
to ignore the warning for all files run 'rvm rvmrc warning ignore all.rvmrcs'.

********************************************************************************
* NOTICE                                                                       *
********************************************************************************
* RVM has encountered a new or modified .rvmrc file in the current directory,  *
* this is a shell script and therefore may contain any shell commands.         *
*                                                                              *
* Examine the contents of this file carefully to be sure the contents are      *
* safe before trusting it!                                                     *
* Do you wish to trust                                                         *
* '/Users/me/apps/Test/.rvmrc'?                                                *
* Choose v[iew] below to view the contents                                     *
********************************************************************************
y[es], n[o], v[iew], c[ancel]> 

輸入y並按Enter鍵后,cron作業現在可以正確執行。

不幸的是,我在cron.log文件中仍然看不到任何內容。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM