java - Unix: Delete File code giving some process -


i have coded java code delete file particular path. able see process running using below command , find 1 entry.

root@ad4d # ps -ef | grep del  root 27896 27895   0   jun 24 pts/5       0:49 java -jar /oracle/php/online/jars/dist/delfile.jar 

but when administrator checks process running command below can see many child threads , parent thread process below

 root@almt4d # ps -aadeflcjlpyz | grep del   s   global    root 27896 27895 26891 26891     1   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891     2   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891     3   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891     4   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891     5   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891     6   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891     7   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891     8   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891     9   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    10   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    11   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    12   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    13   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    14   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    15   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    16   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    17   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    18   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    19   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    20   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    21   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    22   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    23   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    24   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    25   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    26   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    27   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    28   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    29   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    30   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    31   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    32   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    33   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    34   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    35   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    36   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    37   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    38   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    39   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    40   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    41   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    42   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    43   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    44   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    45   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    46   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    47   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    48   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    49   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    50   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    51   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    52   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    53   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    54   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    55   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    56   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    57   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    58   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    59   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    60   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    61   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    62   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    63   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    64   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    65   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    66   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    67   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    68   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    69   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    70   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    71   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    72   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    73   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    74   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    75   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    76   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    77   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    78   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    79   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    80   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    81   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    82   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    83   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    84   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    85   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    86   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    87   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    88   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:04 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    89   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    90   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    91   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    92   -    96   ts  58 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    93   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    94   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    95   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:45 java -jar /oracle/php/online/jars/d  s   global    root 27896 27895 26891 26891    96   -    96   ts  59 37144 116392        ?   jun 24 pts/5       0:00 java -jar /oracle/php/online/jars/d 

can please explain these kind of child , parent thread process started executing. have executed 1 delfile.java has 1 thread there anyway control child threads visible administrator using below command

root@almt4d # ps -aadeflcjlpyz | grep del  

delfile.java

package delfile; import java.io.file; import java.io.ioexception; import java.util.date; import org.apache.log4j.fileappender; import org.apache.log4j.logger; import org.apache.log4j.patternlayout; import org.apache.log4j.simplelayout; public class delfile extends thread{      static logger log =logger.getlogger(delfile.class);      fileappender app = null;      public delfile()throws ioexception{          app = new fileappender(new simplelayout(), "/oracle/php/online/jars/dist/del_file.log");       }      public void logset(){         app.setlayout(new patternlayout(("%d{yyyy-mm-dd hh:mm:ss}  %-5.5p  [%t] %m%n")));         log.addappender(app);      }      boolean flage=true; public void run(){      while(flage){          final string str="xls";          string add="/oracle/php/online/jars/dist/";           string[] paths;          file f = null;           try{               f = new file(add);          paths=f.list();          for(string path:paths)          {                string temp="";             string temp1="";             int count=0;                  for(int i=path.length()-1;i>=0;i--){                      if(path.charat(i)!='.'){                         count++;                          temp+=path.charat(i);//pmbs                                                                  }else{                      for(int j=temp.length()-1;j>=0;j--){                         temp1+=temp.charat(j);                         }                         if(str.length()==count){                         break;                         }                      }                 }                 if(str.equals(temp1)){                         long time= new file(add+path).lastmodified();                         long utime=time+600000l;                         while(utime>system.currenttimemillis()){                            thread.sleep(601000);                         }                            logset();                            log.info(path +"  :  file deleted");                            new file(add+path).delete();                 }                           }         }catch(nullpointerexception np){              try{                 thread.sleep(600000);             }catch(interruptedexception ip) {}                     }catch(interruptedexception ie){         }     } } public static void main(string[] args)throws ioexception{            delfile r=new delfile();            r.start();               } } 

boolean flage=true; public void run(){     while(flage){          // flage not referenced below, no break, no return          ...     } 

this called endless loop. causes thread run ever, explains many entries seen ps.

later

the lwps (or threads) see jvm internal threads - not threads created program. thought worried why they'd remain in machine, apparently ever, indeed due endless loop: program doesn't terminate after files gone.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -