2014-01-23 74 views
0

我需要每週發送一些電子郵件。 我安裝了郵件程序並做了幾次測試。工作正常。每當+梅勒不在一起工作

但我不能使用每當自動發送電子郵件。 已經在各種論壇中搜索,仍然無法修復。

型號/ HrCurriculumIntern

def self.send_reply_interns 
    @users = HrCurriculumIntern.where(:answer_sent => t('labels.n')) 
    InternMailer.send_reply_interns(@users).deliver 
end 

梅勒/ InternMailer

default :from => "[email protected]" 

def send_reply_interns(users) 
    @users = users 
    mail(:to => "<[email protected]>", :subject => t('subjects.send_reply_interns'), :from => "[email protected]") 
end 

配置/ schedule.rb

set :environment, :development 

every 2.minutes do 
runner "HrCurriculumInterns.send_reply_interns" 
end 

我跟着這個步驟: 銪SEGUI埃斯蒂斯帕蘇斯:

發生故障。

每當

0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * * /bin/bash -l -c 'cd /var/www/form/3216/email/trunk && script/rails runner -e development '\''HrCurriculumInterns.send_reply_interns'\''' 

## [message] Above is your schedule file converted to cron syntax; your crontab file was not updated. 
## [message] Run `whenever --help' for more options. 

每當-update-的crontab

0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * * /bin/bash -l -c 'cd /var/www/form/3216/email/trunk && script/rails runner -e development '\''HrCurriculumInterns.send_reply_interns'\''' 

## [message] Above is your schedule file converted to cron syntax; your crontab file was not updated. 
## [message] Run `whenever --help' for more options. 

我看不到的問題,任何建議嗎?

+1

在你的項目文件夾中,運行tail -f log/*。這將顯示所有包含cron的日誌。如果cron運行或不運行,請留意。保留一些記錄器來驗證。調試它。 – Bijendra

回答

1

使用快捷方式「每當-w」寫入crontab。看起來你使用「when -update-crontab」而不是「when --update-crontab」。所以你的命令都沒有寫crontab文件。響應應該是

[write] crontab file updated 

之後,使用「crontab -l」來驗證是否寫入了正確的cron。

0

我找到了解決方案。

我的代碼錯了。我做了一些改變:

梅勒/ intern_mailer.rb

def send_reply_interns 
    @users = HrCurriculumIntern.where(:answer_sent => t('labels.n')) 
    mail(:to => "<[email protected]>", :subject => t('subjects.send_reply_interns'), :from => "[email protected]") 
end 

型號/ hr_curriculum_intern.rb

def self.send_reply_interns 
    InternMailer.send_reply_interns.deliver 
end 

schedule.rb

set :environment, :development 

every 2.minutes do 
    runner "HrCurriculumIntern.send_reply_interns" 
end 

它現在的作品\ O/

謝謝回覆