我在哪里可以找到我的日志文件?

时间:2021-08-04 08:01:52

I'm using the whenever gem for Rails 5. I'm trying to troubleshoot an issue, and after my default schedule.rb file was created at config/schedule.rb, I added some logging directives

我正在使用Rails 5的每个gem。我正在尝试解决问题,并且在config / schedule.rb创建了我的默认schedule.rb文件之后,我添加了一些日志记录指令

# Learn more: http://github.com/javan/whenever
set :environment, "development"

every 10.minutes do
  rake "events:calc_index", :output => {:error => 'error.log', :standard => 'cron.log'}
end

I restarted my Rails server (not sure if that matters or not) but I don't see these log files created anywhere. I have verified my crontab was set up by running "crontab -e" and seeing the job

我重新启动了我的Rails服务器(不确定这是否重要)但我没有看到这些日志文件在任何地方创建。我已经验证了我的crontab是通过运行“crontab -e”并查看作业来设置的

0,10,20,30,40,50 * * * * /bin/bash -l -c 'cd /Users/davea/Documents/workspace/newproj && RAILS_ENV=development bundle exec rake events:calc_index '

Where are the log files created?

日志文件在哪里创建?

1 个解决方案

#1


0  

In your schedule.rb file you can specify the redirection options for your commands at a global or command level by setting the 'output' variable. This example is global level:

在schedule.rb文件中,您可以通过设置'output'变量在全局或命令级别为命令指定重定向选项。这个例子是全球性的:

  # adds ">> /path/to/file.log 2>&1" to all commands
  set :output, '/path/to/file.log'

and you should put this global level set :output above your job definition, otherwise it wouldn't work Example:

你应该把这个全局级别设置:输出高于你的作业定义,否则它将不起作用示例:

# This works
set :output, {:error => '~/Desktop/z.error.log', :standard => '~/Desktop/z.standard.log'}

every 1.minute do
  command "python ~/Desktop/whe/config/z.py"
end

Taken from: https://github.com/javan/whenever/wiki/Output-redirection-aka-logging-your-cron-jobs

取自:https://github.com/javan/whenever/wiki/Output-redirection-aka-logging-your-cron-jobs

#1


0  

In your schedule.rb file you can specify the redirection options for your commands at a global or command level by setting the 'output' variable. This example is global level:

在schedule.rb文件中,您可以通过设置'output'变量在全局或命令级别为命令指定重定向选项。这个例子是全球性的:

  # adds ">> /path/to/file.log 2>&1" to all commands
  set :output, '/path/to/file.log'

and you should put this global level set :output above your job definition, otherwise it wouldn't work Example:

你应该把这个全局级别设置:输出高于你的作业定义,否则它将不起作用示例:

# This works
set :output, {:error => '~/Desktop/z.error.log', :standard => '~/Desktop/z.standard.log'}

every 1.minute do
  command "python ~/Desktop/whe/config/z.py"
end

Taken from: https://github.com/javan/whenever/wiki/Output-redirection-aka-logging-your-cron-jobs

取自:https://github.com/javan/whenever/wiki/Output-redirection-aka-logging-your-cron-jobs