Rails cron 与每当
我不明白为什么“每当”不起作用
Schedule.rb
every 2.minutes do
runner "Ping.check_pings"
end
Ping.rb
class Ping < ActiveRecord::Base
attr_accessible :LAN, :WAN, :info, :infastructure_id
def self.check_pings
@monitor_ping = Ping.new()
@monitor_ping.WAN = "true"
@monitor_ping.save
end
end
crontab -l
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 /home/ruben/Monitoring && script/rails runner -e production '\''Ping.check_pings'\'''
Rails runner "Ping.check_pings" ==>在命令行中工作
我尝试在“rails s”中运行我的项目,但没有 我做错了什么?
I don't understand why "whenever" does not work
Schedule.rb
every 2.minutes do
runner "Ping.check_pings"
end
Ping.rb
class Ping < ActiveRecord::Base
attr_accessible :LAN, :WAN, :info, :infastructure_id
def self.check_pings
@monitor_ping = Ping.new()
@monitor_ping.WAN = "true"
@monitor_ping.save
end
end
crontab -l
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 /home/ruben/Monitoring && script/rails runner -e production '\''Ping.check_pings'\'''
rails runner "Ping.check_pings"
==> Works in command line
I tried it with my project running in "rails s" and without
What am i doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我只是猜测,但是...您是在开发还是生产中进行测试?
如果您正在开发中,请不要忘记安排您的日程安排。rb:
您也可以这样做:
问候
伊万
I am just guessing, but... Are you testing on development or production?.
If your are in development, don't forget to put on your schedule.rb:
Also you can do this:
Regards
Ivan
我认为该字符串上的字符转义不正确;看看
生产'\''
部分,第一个'
关闭了字符串,然后你在没有打开字符串的情况下转义了'
。试试这个:或这个:
或这个:(
您可能根本不需要在单个 shell 单词周围加上引号。:)
I think the character escaping is incorrect on this string; look at the
production '\''
piece, the first'
closes the string, then you're escaping a'
without a string being open. Try this:or this:
or this:
(you might not need quotes around the single shell-word at all. :)