[[PageOutline]] = misc = * [http://it.kndb.jp/entry/show/id/2484 scriptやscreentで取ったLinuxログファイルの文字化けを直す方法 - Knowledge Database IT] * colコマンドでバッククォートとラインフィードを取り除く {{{ # col -bx < {変換前ファイル名} > {変換後ファイル名} }}} * [http://serverfault.com/questions/63705/how-to-pipe-stderr-without-piping-stdout unix - How to pipe stderr without piping stdout - Server Fault] > To do that, use one extra file descriptor to switch stderr and stdout: > {{{ > find /var/log 3>&1 1>&2 2>&3 | tee foo.file > }}} * stdoutをファイルにリダイレクトしつつ、stderrをpipe処理したいときは以下のようにする (bash) * ls -la /var/tmp /var/tmp/hoge 2> stdout 3>&1 1>&2 2>&3 | wc; echo -----; cat stdout {{{ 1 7 45 ----- /var/tmp: total 16 drwxrwxrwt 2 root root 4096 Apr 20 04:42 . drwxr-xr-x 28 root root 4096 May 17 2010 .. }}} * [http://nippondanji.blogspot.com/2011/11/less.html 漢(オトコ)のコンピュータ道: lessでソースコードに色をつける] > 結論から言うと、今日紹介する方法はGNU Source-highlightを使う。 > {{{ > shell> export LESS='-R' > shell> export LESSOPEN='| /usr/share/source-highlight/src-hilite-lesspipe.sh %s' > }}} = screen = * [http://www.dekaino.net/screen/ Let's use SCREEN!] * [http://d.hatena.ne.jp/yanma_4/20080330/1206803656 screenで覚えたことメモ - 半無限長キープ] * [http://haginov.blog35.fc2.com/blog-entry-59.html ほえほえ screen] * [http://d.hatena.ne.jp/naoya/20051223/1135351050 GNU screen いろいろまとめ。 - naoyaのはてなダイアリー] * [http://uwi.but.jp/blog/archives/2008/02/screen-cannot-o.html screen: Cannot open your terminal '/dev/pts/0' - please check. - それ] * sample of .screenrc -> source:/trunk/TipAndDoc/.screenrc * http://svn.ac-room.org/flast/browser/rc/.screenrc * written by @Flast_RO == favorite shortcut == * エスケープキーを Ctrl+X(C-x)とする * ウィンドウ変更 * C-x Space / C-x Backspace または C-x n / C-x p(前後) * C-x 0 / C-x 1 ... (番号指定) * Copy mode * C-x Esc (もう一度Escで終了) * ウィンドウ名の変更 * C-x Shift+A (thanks to twitter:ayokura/status/126956273659944960) == screen with script command == * screen と script を同時に「.bash_profile」内に書くことは出来ない * scriptを先に書いた場合、scriptからexitした後でscreenが起動する {{{ /usr/bin/script ~/.script/`date +%y-%m-%d_%H%M%S`.log /usr/bin/screen -d -RR -U }}} * Script started, file is XXXX -> $ exit -> Script done -> new screen... -> [screen is terminating] * screenを先に書いた場合、screenがterminateした後でscriptが起動する {{{ /usr/bin/screen -d -RR -U /usr/bin/script ~/.script/`date +%y-%m-%d_%H%M%S`.log }}} * [screen is terminating] -> Script started, file is XXXX -> $ exit -> Script done == logging to file on screen == * .screenrc に以下のように書く {{{ logfile /home/mitty/.screen/logfile%Y%m%d%c.%n deflog on }}} * logfile ~/.screen~~ の様に相対パスでは不可?(調査中 * パーセントパラメタの詳細が知りたい * 「logfile20090917 2:07.0」の様なファイルが出来る。 * => attachment:screen.c#L2396 {{{ %d -> 2桁 日(01~31) %D -> 3桁 曜日(Sun~Sat) %m -> 2桁 月(01~12) %M -> 3桁 月(Jan~Dec) %y -> 2桁 年 %Y -> 4桁 年 %a -> am / pm %A -> AM / PM %s -> 2桁 秒(00~59) %c -> sprintf(p, zeroflg ? "%02d:%02d" : "%2d:%02d", tm->tm_hour, tm->tm_min); %C -> sprintf(p, zeroflg ? "%02d:%02d" : "%2d:%02d", (tm->tm_hour + 11) % 12 + 1, tm->tm_min); %H -> HostName %n -> win->w_number }}} == daemonize == * [http://d.hatena.ne.jp/is0me/20100106/1262754530 プロセスのバックグラウンド化(nohupとdisown) - Notes.] * [http://ecpplus.net/weblog/nohup-%e3%81%a8-disown/ nohup と disown « 変なヤバいもんログ] * http://twitter.com/mittyorz/status/6727002820186112 1. zshでは「$ command &!」が使える 1. bashでは不可