トップ «前の日記(2015-07-26) 最新 次の日記(2015-07-28)» 編集

ヨタの日々

2001|08|09|10|11|12|
2002|01|02|03|04|05|06|07|08|09|10|11|12|
2003|01|02|03|04|05|06|07|08|09|10|11|12|
2004|01|02|03|04|05|06|07|08|09|10|11|12|
2005|01|02|03|04|05|06|07|08|09|10|11|12|
2006|01|02|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|11|12|
2012|01|02|03|04|05|06|07|08|09|10|11|12|
2013|01|02|03|04|05|06|07|08|09|10|11|12|
2014|01|02|03|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|08|09|10|11|12|
2016|01|02|03|04|05|06|07|08|09|10|11|12|
2017|01|02|03|04|05|06|07|08|09|10|11|12|
2018|01|02|03|04|05|06|07|08|09|10|11|12|
2019|01|02|03|04|05|06|07|08|09|10|11|12|
2020|01|02|03|04|05|06|07|08|09|10|11|12|
2021|01|02|03|04|05|06|07|08|09|10|11|12|
2022|01|02|03|04|05|06|07|08|09|10|11|12|
2023|01|02|03|04|05|06|07|08|12|
2024|01|02|03|04|

2015-07-27 :-(

_ 午前

0530 起床

0720 食堂

0800 労働

_ 午後

1300 労働

1615 退勤

1630 雑談

_

1700 退勤

1900 筋トレ

2000 gnuplot

2100 飯。鮭のムニエル

_ 買い物

amazon

4774142166

4774140155

_ [ruby][gnuplot][グラフ]ruby gnuplot でグラフを出力したが LANG を設定してなかったので文字化けした

rdp/ruby_gnuplot

手元では動作確認していて、いざ crontab に登録して実行してみたら文字化けしていた。なんでだろ~なんでだろ~と 0.3 秒ほど crontab -l を眺めた

% crontab -l
#MAILTO="miwarin@gmail.com"
MAILTO=""
PATH=/usr/pkg/bin:/usr/pkg/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/localbin:/usr/local/sbin

もしかして

% env -i PATH=/usr/bin:/bin:/usr/pkg/bin:/usr/local/bin ruby22 g01.rb

当たりだった。手元でも再現した。

s01.png

しかも怒られていた。

Could not set character size when opening font "arial", using internal non-scalable font

LANG をつけるのが正解。

% env -i LANG=ja_JP.UTF-8 PATH=/usr/bin:/bin:/usr/pkg/bin:/usr/local/bin ruby22 g01.rb

s02.png

crontab にも LANG を設定しましょうというオチだった。他のプログラム? 知らんね。

% crontab -l
#MAILTO="miwarin@gmail.com"
MAILTO=""
PATH=/usr/pkg/bin:/usr/pkg/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/localbin:/usr/local/sbin
LANG=ja_JP.UTF-8

こういうコード。example の sin_wave.rb まま

#: coding utf-8

require "gnuplot"

Gnuplot.open do |gp|
  Gnuplot::Plot.new( gp ) do |plot|
    plot.terminal "png"
    plot.output File.expand_path("../sin_wave.png", __FILE__)
    plot.xrange "[-10:10]"
    plot.title  "Sin カーブ"
    plot.ylabel "sin(x)"
    plot.xlabel "x"
    plot.data << Gnuplot::DataSet.new( "sin(x)" ) do |ds|
      ds.with = "lines"
      ds.linewidth = 4
    end
  end
end
puts 'created sin_wave.png'