Results 1 to 16 of 16
  1. #1
    laungarth is offline Member
    Join Date
    Jul 2011
    Posts
    10
    Rep Power
    0

    Default How I am going to write process to excute batch job on particular date.

    Hi every body,

    I have some question about how i going to write process to execute on particular date.

    Assumption:

    1. I need to write Action class which can execute batch process.

    2. It needs to has a condition.
    2.1 process will go back to check the last successful run date.
    2.1 when process found the date, it will start to run batch job from that date + 1 (next day of last successful run date) to system date - 1.

    (EX. Batch job was ran on last Friday but it fail to run on Sat and Sunday. So, we found out on next Monday. We need to run batch process for result on Saturday and Sunday)

    Thank you in advance.

    Newbie
    Last edited by laungarth; 07-06-2011 at 09:34 PM.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,457
    Rep Power
    25

    Default

    You have left off your questions.

  3. #3
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default

    You have left off your questions.
    Indeed.

    Double posted: how to write process to execute batch job on particular date.

  4. #4
    laungarth is offline Member
    Join Date
    Jul 2011
    Posts
    10
    Rep Power
    0

    Default

    I am confused. Which part do I need to add?

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,457
    Rep Power
    25

    Default

    Your questions about how YOU are going to write your code. So far you've stated your assignment.

  6. #6
    laungarth is offline Member
    Join Date
    Jul 2011
    Posts
    10
    Rep Power
    0

    Default

    Got you.

    So How I am going to write it. Please help

  7. #7
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default

    And again...these multiple posts do not help you receive help any faster, and in fact clutter up the forums so much that it could discourage someone from helping
    how to write process to execute batch jop on particular date.

  8. #8
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,457
    Rep Power
    25

    Default

    Why have you been assigned this program if you have no idea how to write it?
    What have you studied so far? How long have you been studying?

  9. #9
    laungarth is offline Member
    Join Date
    Jul 2011
    Posts
    10
    Rep Power
    0

    Default

    Why you have to be so difficult? I though I could seek help or idea from this forum. If my question was so irritating for you, I could not help.

  10. #10
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,457
    Rep Power
    25

    Default

    Sorry, I thought you were asking someone to write your program for you.

    What do you have that we could help you with?

  11. #11
    laungarth is offline Member
    Join Date
    Jul 2011
    Posts
    10
    Rep Power
    0

    Default

    My apology,

    I used work on batch process in shell scripting. I have not worked much on java, but got this assignment since they want me to get a chance to work more on java.

    By far, I do some research but did not see much example. My idea is to have method to execute batch process which have condition to look for last successful run date. I goggled and found most of outcome will be like

    Runtime rt = Runtime.getRuntime();
    Process proc = runtime.exec(cmd);

    If i need to put "if condition" to find the"last run date", where should I put it in.

    Thank you,

  12. #12
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,457
    Rep Power
    25

    Default

    If i need to put "if condition" to find the"last run date", where should I put it in.
    Is this an attempt to design the project? Where does the data come from for the run dates?
    How should they be compared and to what other dates?
    Can you supply a bit more logic and the program steps that are needed.

    Those two classes you posted can be used to execute an external command like a batch file.

  13. #13
    laungarth is offline Member
    Join Date
    Jul 2011
    Posts
    10
    Rep Power
    0

    Default

    Yes, it is only design. I am working on the logic and some sample code for document. Data will come from XML stream.

    My design will start from looking for max date which by run query from DAO.


    ******* Query query = session.createSQLQuery( "SELECT max(DATE) as max_date FROM ActivityLog")


    After that, I want to take that value to use in Action class.

    My action class will be something like

    ******
    public class ActivityFileAction extends Action{

    String dt = “yyyy-mm-dd”;
    SimpleDateFormat sdt = new SimpleDateFormat(“yyyy-mm-dd”);
    Calender c = Calender.getInstance();
    c.setTime(sdf.parse(dt));

    Process exec {
    If (dt != sysdate)

    Return
    c.add(Calender.DATE, 1); //number of day to add
    dt = sdf.farmat(c.getTime()); //dt is now the run date

    //System start to excute batch process with for loop

    }

    }


    I am still trying to figure out the way to execute batch process with "for loop". I am not sure the logic is right. If you have other idea, pls let me know.
    Last edited by laungarth; 07-07-2011 at 09:10 PM.

  14. #14
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,457
    Rep Power
    25

    Default

    My design will start from looking for max date
    Then what?

    I still figure out the way to execute batch process with "for loop
    Why the for loop? How many batch processes do you want to generate at a time?

  15. #15
    laungarth is offline Member
    Join Date
    Jul 2011
    Posts
    10
    Rep Power
    0

    Default

    The max date in the log file will show the last success run date. If max date is not sysdate, means batch process failed. I take the max date plus one (c.add(Calender.DATE, 1); //number of day to add) which will be first date that the batch was failed.

    In case of batch job fail to run for couple days. System will run batch process from the first fail date to system date - 1. I use for loop to run batch process for everyday that it fail.

    Does it make sense?

  16. #16
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,457
    Rep Power
    25

Similar Threads

  1. Replies: 5
    Last Post: 02-16-2012, 09:26 AM
  2. excute cmd command
    By jperson in forum New To Java
    Replies: 2
    Last Post: 01-27-2011, 04:20 PM
  3. excute cmd command
    By jperson in forum New To Java
    Replies: 4
    Last Post: 11-11-2010, 03:00 PM
  4. excute command
    By jperson in forum New To Java
    Replies: 4
    Last Post: 07-13-2010, 08:48 AM
  5. Help how to write the date
    By kjiu in forum New To Java
    Replies: 2
    Last Post: 11-01-2009, 04:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •