VERA
VERA

Reputation: 13

Crontab run a ruby file not work

*/1 * * * * ~/.rbenv/versions/2.1.5/bin/ruby /Users/zhangjian/Desktop/mail.rb

*/1 * * * * /usr/bin/ruby /Users/zhangjian/Desktop/OHS_Project/ohs_server/rest/notification.rb

I write these 2 under crontab e but it doesn't work. I try run the file directively, everything works.

aFile = File.new("./time.txt", "a+")
if aFile
   aFile.syswrite(Time.new.inspect)
   aFile.syswrite("                     ")
else
   puts "Unable to open file!"
end

how can I fix it?

Upvotes: 1

Views: 53

Answers (1)

NaN
NaN

Reputation: 8601

Try using the full path without ~ in the crontab. You should also try to use an absolute path when referencing time.txt.

Upvotes: 1

Related Questions