Class ScriptUtil

java.lang.Object
com.xxl.job.core.util.ScriptUtil

public class ScriptUtil extends Object
1、内嵌编译器如"PythonInterpreter"无法引用扩展包,因此推荐使用java调用控制台进程方式"Runtime.getRuntime().exec()"来运行脚本(shell或python); 2、因为通过java调用控制台进程方式实现,需要保证目标机器PATH路径正确配置对应编译器; 3、暂时脚本执行日志只能在脚本执行结束后一次性获取,无法保证实时性;因此为确保日志实时性,可改为将脚本打印的日志存储在指定的日志文件上; 4、python 异常输出优先级高于标准输出,体现在Log文件中,因此推荐通过logging方式打日志保持和异常信息一致;否则用prinf日志顺序会错乱 Created by xuxueli on 17/2/25.
  • Constructor Details

    • ScriptUtil

      public ScriptUtil()
  • Method Details

    • markScriptFile

      public static void markScriptFile(String scriptFileName, String content) throws IOException
      make script file
      Parameters:
      scriptFileName -
      content -
      Throws:
      IOException
    • execToFile

      public static int execToFile(String command, String scriptFile, String logFile, String... params) throws IOException
      脚本执行,日志文件实时输出
      Parameters:
      command -
      scriptFile -
      logFile -
      params -
      Returns:
      Throws:
      IOException