Create a custom Jobfile

By default all job output is written to the stdout.log file. However it is possible to create a custom JobFile in RedwoodScript.

      import java.io.PrintWriter;
import com.redwood.scheduler.api.model.Job;
import com.redwood.scheduler.api.model.JobFile;
import com.redwood.scheduler.api.model.enumeration.JobFileType ;
import com.redwood.scheduler.api.model.Format ;  
import java.io.*;
{
  
  // Create a custum csv JobFile
  
  // Create the JobFile
  JobFile outCsvFile = jcsJob.createJobFile(); 
  
  // Set type to output so it is writable
  outCsvFile.setFileType(JobFileType.Output); 
  
  // Set the format to CSV
  outCsvFile.setFormat(jcsSession.getFormatByName(Format.CSV)); 
  
  // Set the order of the JobFile.
  outCsvFile.setOrder(new Long (1300001)); 
  
  // Set the filename
  outCsvFile.setName("report.csv"); 
  outCsvFile.setFileNameAutomatic(); 
  
  // Get the real filename so the file can be opened for write-actions
  String realFileName = outCsvFile.getFileName(); 
 
  // Commit the creation of the JobFile
  jcsSession.persist();   	 	
  
  // Open a FileWriter to the file
  File f = new File(realFileName); 
  final FileWriter fWriter1= new FileWriter(f);

  fWriter1.write("This;is;a;test" + "\r\n" ) ; 

  // Close the FileWriter
  fWriter1.close() ;

}