프로세스가 시작한 시간 구하기
글쓴이: zflute / 작성시간: 월, 2004/06/28 - 12:16오후
python으로 개발된 child 프로그램이 타임아웃이 잘 먹지 않아서 cron 을 이용해서 실행된 후에 일정 시간이 지난 프로그램을 kill 하려고 합니다.
ps 명령어를 실행시켜서 보면 START 부분이 프로세스가 실행된 시간인데, /proc/PID/stat를 읽어와서 뿌려주는 것 같은데, stat에서 어떤 부분이 start time인지 알 수가 없네요.
$ cat stat 20804 (python) S 29977 29975 29975 0 -1 0 2478 25668 955 3410 16 22 87 36 15 0 0 6000 77954307 8777728 997 4294967295 134512640 135281960 3221222864 3221220600 4294959106 0 2147221247 16781313 8194 3222461405 0 0 17 1 0 0 16 22 87 36
여기서 start time에 해당하는 부분은 어딘가요?
참고로 구글에서 찾은바로는,
int pid; /** The process id. **/
char exName [_POSIX_PATH_MAX]; /** The filename of the executable **/
char state; /** 1 **/ /** R is running, S is sleeping,
D is sleeping in an uninterruptible wait,
Z is zombie, T is traced or stopped **/
unsigned euid, /** effective user id **/
egid; /** effective group id */
int ppid; /** The pid of the parent. **/
int pgrp; /** The pgrp of the process. **/
int session; /** The session id of the process. **/
int tty; /** The tty the process uses **/
int tpgid; /** (too long) **/
unsigned int flags; /** The flags of the process. **/
unsigned int minflt; /** The number of minor faults **/
unsigned int cminflt; /** The number of minor faults with childs **/
unsigned int majflt; /** The number of major faults **/
unsigned int cmajflt; /** The number of major faults with childs **/
int utime; /** user mode jiffies **/
int stime; /** kernel mode jiffies **/
int cutime; /** user mode jiffies with childs **/
int cstime; /** kernel mode jiffies with childs **/
int counter; /** process's next timeslice **/
int priority; /** the standard nice value, plus fifteen **/
unsigned int timeout; /** The time in jiffies of the next timeout **/
unsigned int itrealvalue; /** The time before the next SIGALRM is sent to the process **/
int starttime; /** 20 **/ /** Time the process started after system boot **/
unsigned int vsize; /** Virtual memory size **/
unsigned int rss; /** Resident Set Size **/
unsigned int rlim; /** Current limit in bytes on the rss **/
unsigned int startcode; /** The address above which program text can run **/
unsigned int endcode; /** The address below which program text can run **/
unsigned int startstack; /** The address of the start of the stack **/
unsigned int kstkesp; /** The current value of ESP **/
unsigned int kstkeip; /** The current value of EIP **/
int signal; /** The bitmap of pending signals **/
int blocked; /** 30 **/ /** The bitmap of blocked signals **/
int sigignore; /** The bitmap of ignored signals **/
int sigcatch; /** The bitmap of catched signals **/
unsigned int wchan; /** 33 **/ /** (too long) **/
int sched, /** scheduler **/
sched_priority; /** scheduler priority **/
인데, 항목을 찾아보면 starttime에 해당하는 값은 1이네요. :?
끝자리가 맞지 않아 좀 이상하긴 하지만...
Forums:


ls -l /proc/#여기서 나온 시간...-_-ㅋ이거면 확실한
ls -l /proc/#
여기서 나온 시간...-_-ㅋ
이거면 확실한거 아닌가요?
저기 아래에서의 값은 글쎄요?
<어떠한 역경에도 굴하지 않는 '하양 지훈'>
#include <com.h> <C2H5OH.h> <woman.h>
do { if (com) hacking(); if (money) drinking(); if (women) loving(); } while (1);
[quote="서지훈"]ls -l /proc/#여기서 나온 시간...
/proc 이하 디렉토리는 계속 갱신되기 때문에 sleep인 프로세스일 경우에도 디렉토리 생성시간은 '현재'로 표시되지 않나요?
삽질을 좀 하다 보니 알아냈네요.22번째 항목(77954307)이네요
삽질을 좀 하다 보니 알아냈네요.
22번째 항목(77954307)이네요. :-)
밀리초 단위라서 끝에 두자리 없애고 86400초로 나누면 부팅된 이후 부터 몇일지 지난 시점에 실행되었는지 알 수 있습니다.
779543 / 86400 = ???
man 5 proc 에 나오는 이야기가 맞죠? :D
man 5 proc 에 나오는 이야기가 맞죠? :D
아.../proc는 가상 파일 시스템인것을...-_-ㅋ일반 파
아...
/proc는 가상 파일 시스템인것을...-_-ㅋ
일반 파일 시스템으로 착각한게아니라...
평소에 관심을 갖기가 않아서 이런 잘못된 답변을 드린것 같군요...-_-ㅋ
무안...-_-ㅋ
<어떠한 역경에도 굴하지 않는 '하양 지훈'>
#include <com.h> <C2H5OH.h> <woman.h>
do { if (com) hacking(); if (money) drinking(); if (women) loving(); } while (1);
[quote="zflute"]삽질을 좀 하다 보니 알아냈네요.22번째
언제나 밀리초 단위인 것은 아닙니다. 자세한 내용은 procps 소스코드를 참고하시면 되고, perl 로 옮겨 쓴 것은 아래에 있습니다. linux kernel 2.4 on single x86 정도에서는 잘 동작합니다.
http://cizz.net/pub/check.pending.pl
War doesnt determine whos right, just whos left.
댓글 달기