我在crontab中有以下条目:
0 5 * * * /bin/bash -l -c 'export RAILS_ENV=my_env; cd /my_folder; ./script/my_script.rb 2>&1 > ./log/my_log.log'
Run Code Online (Sandbox Code Playgroud)
这样做的结果是,我收到的输出./script/my_script.rb在./log/my_log.log.这种行为是期望的.奇怪的是,我也在本地邮件中收到输出.我想知道如何通过邮件捕获我的脚本的输出.由于我将输出重定向到日志文件,我希望我的cron作业没有输出,因此当cron作业运行时我不会收到任何邮件.任何人都可以了解邮件如何获得输出./script/my_script.rb?
这是我的设置,然后解释我想要完成的任务.
class Layer < ActiveRecord::Base
has_and_belongs_to_many :components
end
class Component < ActiveRecord::Base
has_and_belongs_to_many :layers
end
class ImageComponent < Component
# I want this table to inherit from the Component table
# I should be able to add image-specific fields to this table
end
class VideoComponent < Component
# I want this table to inherit from the Component table
# I should be able to add video-specific fields to this table
end
Run Code Online (Sandbox Code Playgroud)
我希望能做什么:
layer.components << ImageComponent.create
layer.components << VideoComponent.create
Run Code Online (Sandbox Code Playgroud)
在实践中,我意识到ImageComponent …