Whenever gem: I install: output, but the log file does not appear where I would expect it

In my file schedule.rb, I have the following lines:

set :output, '/log/cron_log.log'

every 5.minutes do
  command 'echo "hello"'
end

I started whenever -w, as suggested in this question, Rails, using every time a stone was created in development , and I assume that the cronfile is written and started. (I also tried restarting the Rails server.)

And when I run $ crontab -l, I see the following:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /bin/bash
-l -c 'echo "hello" >> /log/cron_log.log 2>&1'

But I can not find the log file. I checked rails_project / log, ~ / log and / log to no avail. On OSX by the way.

How can I write a log file to the rails project's log folder?

+5
source share
1 answer

Where is your magazine located?

:

$ cd /log

, :

$ ls -la cron_log.log

, :

$ touch cron_log.log

( !)

$ chmod +rw cron_log.log  

?

, , , :

$ /bin/bash -l -c 'echo "hello" >> /log/cron_log.log 2>&1'

, :

wrong: command 'echo "hello"'
right: command '/bin/echo "hello"'

:

$ which echo

, cron , :

$ sudo grep CRON /var/log/syslog

grep , - :

Jan 1 12:00:00 example.com CRON[123]: (root) CMD (... your command here ...)

Mac?

syslog Mac, Mac OSX cron launchd.

. cron plist (/System/Library/LaunchDaemons/com.vix.cron.plist) stdout/stderr cron. , plist, , . (. cron )

Rails?

Rails, ( cron.log)

set :output, "log/cron.log"

:

set :output, '/abc/def/ghi/log/cron.log'

, wiki :

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

:

every 3.hours do
  runner "MyModel.some_process", :output => 'cron.log'     
  rake "my:rake:task", :output => {:error => 'error.log', :standard => 'cron.log'}
  command "/usr/bin/cmd"
end  
+30

All Articles