unix时间戳转换

Posted by 4Aiur on 05/14/2010 in SysAdmin |

unix时间戳转换, Convert unix timestamp utime(){ date -d @$1; } utime(){ date -d “1970-01-01 GMT $1 seconds”; } utime(){ awk -v d=$1 ‘BEGIN{print strftime(“%a %b %d %H:%M:%S %Y”, d)}’; } utime(){ perl -e “print localtime($1).\”\n\””; } utime(){ python -c “import time; print(time.strftime(‘%a %b %d %H:%M:%S %Y’, time.localtime($1)))”; } [root@test test]# utime(){ date -d @$1; } [root@test test]# […]

Tags:

查找使用中的文件与目录相关信息

Posted by 4Aiur on 05/10/2010 in SysAdmin |

查找使用中的文件与目录相关信息 以tmp目录为例,使用下面得方法获得使用tmp目录进程的相关信息。 [root@4aiur ~]# inode=stat -c %i tmp [root@4aiur ~]# cd tmp [root@4aiur ~]# lsof -n | awk -v a=$inode ‘a==$(NF-1) || a==$(NF-2)’ bash 1963 root cwd DIR 253,0 4096 23805953 /root/tmp lsof 2033 root cwd DIR 253,0 4096 23805953 /root/tmp awk 2034 root cwd DIR 253,0 4096 23805953 /root/tmp lsof 2035 root cwd DIR […]

Tags:

python的ftp应用举例

Posted by 4Aiur on 05/04/2010 in Python |

python的ftp应用举例 使用python可以很方便的进行ftp操作,下面这个小程序的作用是成功下载远程服务器文件后,删除远程服务器上面的文件。 #!/usr/bin/env python2 # -*- coding: utf-8 -*- from ftplib import FTP import logging import os import socket logger = logging.getLogger(“download”) logger.setLevel(logging.DEBUG) fh = logging.FileHandler(“download.log”) formatter = logging.Formatter(“%(asctime)s – %(name)s – %(levelname)s – %(message)s”) fh.setFormatter(formatter) logger.addHandler(fh) def get_del(): ip = ‘127.0.0.1’ user_name = ‘foo’ passwd = ‘bar’ source_path = ‘/test_sour_dir/’ try: ftp = FTP(ip) […]

Tags:

Copyright © 2010-2019 4Aiur All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.