파일의 생성, 수정, 접근 시간 알아보기

|
One is the number
of seconds since the Epoch, in UTC (a.k.a. GMT).  It may be an integer
or a floating point number (to represent fractions of seconds).
The Epoch is system-defined; on Unix, it is generally January 1st, 1970

import os
os.path.getctime(패스)
os.path.getmtime(패스)
.. .



getatime( path)

Return the time of last access of path. The return value is a number giving the number of seconds since the epoch (see the time module). Raise os.error if the file does not exist or is inaccessible. New in version 1.5.2. Changed in version 2.3: If os.stat_float_times() returns True, the result is a floating point number.

getmtime( path)

Return the time of last modification of path. The return value is a number giving the number of seconds since the epoch (see the time module). Raise os.error if the file does not exist or is inaccessible. New in version 1.5.2. Changed in version 2.3: If os.stat_float_times() returns True, the result is a floating point number.

getctime( path)

Return the time of creation of path. The return value is a number giving the number of seconds since the epoch (see the time module). Raise os.error if the file does not exist or is inaccessible. New in version 2.3.

getsize( path)

Return the size, in bytes, of path. Raise os.error if the file does not exist or is inaccessible. New in version 1.5.2.
And

쉘스크립트 수행후 결과 (stdout) 얻어오기

|
import os
stdin, stdout = os.popen2('du -sh')
print stdout.redlines()
stdin.close()
stdout.close()


하면 결과실행한 값을 알수 있다.
또는 
temp = stdout.readlines() 하면 리스트 형태로 temp리스트에 결과값이 저장된다.
이것은 명령어 입력값을 바꾸고 싶을때 사용한다


단순히 실행한 파일의 stdout만을 가져오고싶다면
import commands
output = commands.getoutput(cmd)   ''' output을 가져온다
status = commands.getstatus(file)     ''' return output of "ls -ld <file>" in a string
statusoutput = commands.getstatusoutput(cmd) ''' return (status, ouput)of executing cmd in a shell

이것은 다음을 실행시키는것과 같다
      pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')
      text = pipe.read()
      sts = pipe.close()
And

rcp

|

현재 내 ip   : 1.1.1.1    (데이터를 보내는 ip)
전송 받을 ip : 2.2.2.2

전송 받을 ip에 /etc/hosts.allow 에 (원격접속을 허락하는 ip를 적는 곳이다.)
in.rshd:1.1.1.1 입력

자신의 계정의 .rhost에 ip를 적어줌 (두개의 서버가 서로다른 계정일 때는
ip뒤에 전송하는 서버의 유저아이디를 적어준다)
xinetd를 kill -SIGHUP을 통해서 죽였다 살려줘서
hosts.allow파일을 리로드하게 해준다

명령어..
/usr/bin/rcp -rp a.tar.gz 2.2.2.2:/home/my

가능하면 압축해서 보내자. 여러파일을 한꺼번에 보내려고하면 느림

And
prev | 1 | ··· | 17 | 18 | 19 | 20 | 21 | next