Affamative Way

前向きにグダグダいいながらコード書く

macで特定期間ループするshスクリプトが書きたい

覚えておける自信がないのでメモ

#!/bin/sh
startdate="2011-04-30"
stopdate="2011-05-03"

cnt=0
while [ 1 ] ;do
  nowdate=`date -v+${cnt}d -j -f "%Y-%m-%d" "${startdate}" +"%Y-%m-%d"`
  echo "shori" ${nowdate}

  if [ ${nowdate} = ${stopdate} ] ; then
    break
  fi
  let cnt=$cnt+1
done

実行結果

% sh date_loop.sh 
shori 2011-04-30
shori 2011-05-01
shori 2011-05-02
shori 2011-05-03

実際使う時は処理をコマンドに置き換えるといいよ!

BSD系のdateのusage: http://www.jp.freebsd.org/cgi/mroff.cgi?sect=1&cmd=&lc=1&subdir=man&dir=jpman-6.0.0%2Fman&man=date#toc

mac上のmysqlで実行ログを見る方法のメモ

my.cnfを設定する

 $ sudo vi /etc/my.cnf

以下を追記する

[mysqld]
:略
log = /var/log/mysql/query.log

ログを準備する

 $ sudo mkdir -p /var/log/mysql/
 $ sudo touch /var/log/mysql/query.log

mysql再起動する

 $ /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper restart

結構便利!!でも、常時は実行してると肥大化するから危険かも。。

MacPortsで入れたphp52のPEARにunsupported protocalとか言われた時の対処メモ

  • なんかPEARがご機嫌ななめ
$ sudo pear install Benchmark
pear.php.net is using a unsupported protocal - This should never happen.
install failed
$ sudo rm /opt/local/lib/php/.channels/pear.php.net.reg
$ sudo rm /opt/local/lib/php/.channels/pecl.php.net.reg
  • 再生成する
$ sudo pear channel-update pear.php.net
Updating channel "pear.php.net"
Update of Channel "pear.php.net" succeeded
  • PEAR本体が古いので更新
$ sudo pear upgrade PEAR
  • 再度試す
$ sudo pear install Benchmark
downloading Benchmark-1.2.7.tgz ...
Starting to download Benchmark-1.2.7.tgz (9,506 bytes)
.....done: 9,506 bytes
install ok: channel://pear.php.net/Benchmark-1.2.7

わーい、ちゃんとうごいたー

Snow leopardにMacPortsでPHP5.2.X環境を作るの巻

ひさかたぶりの更新

雪豹入れたらMacPortsが使えなくなるとか、PHPが5.3だったりしたので環境構築やり直しのメモ

Mac OS X 10.6 Snow Leopard
Mac OS X 10.6 Snow Leopard
posted with amazlet at 09.09.22
アップルコンピュータ (2009-08-28)
売り上げランキング: 5

続きを読む