六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 85|回复: 0

ubuntu上python小工具部署操作

[复制链接]

升级  36%

4

主题

4

主题

4

主题

童生

Rank: 1

积分
18
 楼主| 发表于 2013-1-15 02:20:19 | 显示全部楼层 |阅读模式
帮朋友写了个小工具, 记录下:
linux命令:
    屏蔽pemission deny:
    find / -name apache 2>/dev/null
   文件拷贝:
    本地到server: scp -p /tmp/New\ Project\ 20100912\ 0015.sql mike@218.76.12.194:/home/mike/
    server到本地: scp -p mike@218.76.12.194:/home/mike/loopSearch.* /tmp/
 
    ubuntu安装MySQLdb: sudo apt-get install python-mysqldb
 
在贴上重启程序的代码:
#!/usr/bin/env bashimport timeimport threadingimport osdef getMem():    memInfo = os.popen("free").read()    infos = memInfo.split()    print infos    return int(infos[9])def startSearch():    os.popen("python XXX.py")if __name__ == "__main__":    print getMem()    ttime = 0    pt = 360    t = threading.Thread(target=startSearch)    t.start()    while(True):        if getMem() < 10000 or ttime > 36000:            break        time.sleep(pt)        ttime += pt getMem获取当前可用内存如果内存小于10M或程序持续运行10小时, 则退出。若要程序重启,可在外层套shell脚本。 
 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表