This is a discussion on Need help in PS command for AIX within the AIX Operating System forums, part of the Unix Operating Systems category; --> Hi The command in AIX (ps -o "start") would give the output in the following format, ps -u dsaudit ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi The command in AIX (ps -o "start") would give the output in the following format, ps -u dsaudit -o start STARTED Feb 01 12:32:04 12:32:00 time the command started. If the process was started less than 24 hours ago, the output format is " HH:MM", else it is "mmm dd" (where mmm is the three letters of the month). But when the same Mac OSx (ps -o lstart) gives the output in the following format. STARTED Thu Feb 9 22:44:12 2006 Tue Feb 14 17:51:45 2006 Thu Feb 9 14:21:16 2006 Thu Feb 9 14:21:17 2006 Is there a way to get the start time in the long format in AIX machines. Please let me know as early as possible. Thanks in advance. Thanks, Ramu Anekere |
| |||
| Hello. Tried 'ps -o etime'? Format is still different from what you want / get on Mac, but it gives you at least the full difference ( [[ dd-]hh:]mm:ss ) Don't now if there are LANG environment tricks to get the full time. Maybe this quick hack might help ps -ef -o etime,args | perl -ne ' { if ($_=~/(? printf("%s %s\n", scalar(localtime(time-(($1*86400)+($2*3600)+($3*60)+$4))),$5) } }' Bye, Stefan ... . . |
| |||
| Thanks a lot for the solution Stefan, But from the above method the process start time sometimes may change. I ran the above chunk of code for a while in a loop ad I got the value differing by one minute. For me the Process start time remaining constant is very important factor. Can you please suggest me some other method. Thanks ageain. Ramu Anekere |
| ||||
| Hello Ramu Are you sure that the difference is (exactly?) a minute and not a _second_? The reason for a short difference is that the perl script uses the difference from the current time and the process elapsed time to calculate the process start time. As there is a small amount of time between the output of the ps command and the start of the script there might be a difference. (But if you aren't running a RS/6000 250 with 20.000 processes it should not take a minute ;-) You might be able do reduce the effect for a large process table by getting the current time in advance. But the problem will not vanish entirely: perl -e ' $T=time; printf("T=%s\n",$T); open(PS,"/usr/bin/ps -eo etime,args|") || die "PS FAILED"; while (defined($L=<PS>)) { if ($L=~/(? print localtime($T-(($1*86400)+($2*3600)+($3*60)+$4)). " ".$5."\n"; } } close(PS); ' If you are depended that the start time does not change between subsequent calls you can o Run ps -eo etime,args 'raw', test if start time has changed. (Don't know how that should happen btw.) If everything is all right continue and convert the time afterwards. o Convince IBM that you need something like 'ps -eo lstart' (If it's not already hidden somewhere). o Help you with the following small C code #include <procinfo.h> #include <sys/types.h> #include <string.h> #include <errno.h> extern int errno; #define TSZ 64 int main() { struct procsinfo pbuf[TSZ]; char *stime; pid_t iptr; int i,j; iptr=(pid_t) 0; while ( (i=getprocs(&pbuf,sizeof(struct procsinfo), 0,0,&iptr,TSZ)) > 0 ) { for (j=0;j<i;j++) { stime=ctime((const time_t*) &pbuf[j].pi_start); stime[strlen(stime)-1]='\0'; printf("%s %s\n", stime, pbuf[j].pi_comm); } } if (i==-1) printf("ERROR: %d (%s)\n",errno,strerror(errno)); return i; } Greetings to India Bye, Stefan ... . . |
| Thread Tools | |
| Display Modes | |
|
|