简体   繁体   中英

Send output from rake to email

Rails 3.1.1 and Heroku

I am running a few Rake-commands every night on my app that is hosted at Heroku. The rake commands produces some puts rows that I would like to read in the morning to see how the updates performed by rake was performed.

Preferably, I would like this info emailed to me and this seems like it should not be too difficult, but what do I need to do?

The rake_notifier gem does not seem to be the solution, since I want the output even when the rake is successful (rake_notifier seems to only send info when the rake crashes).

Update: I do not know ruby well enough so I have probably missed out on very simple solutions. The problems is just as much to "gather" that data. Emailing it to me is the next step in the problem chain. Right now I am only checking my logs and they are flooded with tons of other data.

in rake task file do the following:

log_string = ""
begin
# type all your code here
# instead of using puts use
log_string += "print log whatever you want" + "\\n\\n"
rescue
# rescue ur code
end
# mail your log_string through a mailer that you are using.


Hence, either your rake task is successful or not, you will get your log in your mail.
Even you can mail yourself, the error message created in rake task, and that you can define in rescue block.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM