2016年4月7日木曜日

.screenrc

Screenの設定ファイルはこんな感じで
term screen-256color
escape ^Oo
termcapinfo xterm* ti@:te@

hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%t%n*%f%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]'
チートシート: http://www.pixelbeat.org/lkdb/screen.html

2016年2月20日土曜日

pythonのスクリプトファイルとの相対パス

import os

this_dir = os.path.dirname(os.path.realpath(__file__))
filename = os.path.join(this_dir, 'lib')
print filename

2016年2月19日金曜日

python によるPID のロック

import time
import os
import sys

pid = str(os.getpid())
pidfile = "/tmp/scripy.pid"

if os.path.isfile(pidfile):
    print "exit"
    sys.exit(0)
file(pidfile, 'w').write(pid)
try:
    f = open('workfile', 'a')
    f.write("1")
    f.close
    time.sleep(10)

finally:
    os.unlink(pidfile)