{"record":{"id":"314a11325eeb6760","repo":"apache/dolphinscheduler","slug":"execute-shell-task-error-314a11","errorCode":null,"errorMessage":"Execute shell task error","messagePattern":"Execute shell task error","errorType":"exception","errorClass":"TaskException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java","lineNumber":81,"sourceCode":"        try {\n            IShellInterceptorBuilder<?, ?> shellActuatorBuilder = ShellInterceptorBuilderFactory.newBuilder()\n                    .properties(ParameterUtils.convert(taskRequest.getPrepareParamsMap()))\n                    .appendScript(shellParameters.getRawScript());\n\n            TaskResponse commandExecuteResult = shellCommandExecutor.run(shellActuatorBuilder, taskCallBack);\n            setExitStatusCode(commandExecuteResult.getExitStatusCode());\n            setProcessId(commandExecuteResult.getProcessId());\n            shellParameters.dealOutParam(shellCommandExecutor.getTaskOutputParams());\n            taskRequest.setVarPool(shellParameters.getVarPool());\n        } catch (InterruptedException e) {\n            Thread.currentThread().interrupt();\n            log.error(\"The current Shell task has been interrupted\", e);\n            setExitStatusCode(EXIT_CODE_FAILURE);\n            throw new TaskException(\"The current Shell task has been interrupted\", e);\n        } catch (Exception e) {\n            log.error(\"shell task error\", e);\n            setExitStatusCode(EXIT_CODE_FAILURE);\n            throw new TaskException(\"Execute shell task error\", e);\n        }\n    }\n\n    @Override\n    public void cancel() throws TaskException {\n        // cancel process\n        try {\n            shellCommandExecutor.cancelApplication();\n        } catch (Exception e) {\n            throw new TaskException(\"cancel application error\", e);\n        }\n    }\n\n    @Override\n    public AbstractParameters getParameters() {\n        return shellParameters;\n    }\n","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java#L63-L99","documentation":"The generic catch-all in ShellTask.handle(): any non-interrupt exception while building or running the shell command (task-prepare failure, command IO errors, executor failures) is logged and rethrown as TaskException(\"Execute shell task error\", e) with exit status EXIT_CODE_FAILURE. The root cause is in the wrapped exception.","triggerScenarios":"ShellCommandExecutor.run() throws for any reason other than InterruptedException — e.g. failure creating the exec temp directory, writing the command file, or reading process output; the shell script exits and the executor itself throws.","commonSituations":"Worker run directory not writable or disk full so the generated .command file cannot be written; interpreter in the shebang missing on the worker; task output param collection failing after execution.","solutions":["Inspect the wrapped cause in the worker log (logged as 'shell task error') to identify the underlying IO or execution failure","Verify the worker's exec path (config execPath/temp dir) exists and is writable by the worker OS user","Run the script's content manually on the worker host as the same user to reproduce the failure outside the scheduler"],"exampleFix":"// before: worker exec dir unwritable\nexecPath: /root/dolphinscheduler/exec\n// after\nexecPath: /opt/dolphinscheduler/exec  # chown dolphinscheduler:dolphinscheduler, chmod 755","handlingStrategy":"try-catch","validationCode":"// preflight on the worker host\ncmd = \"test -w \" + execPath + \" && df -h \" + execPath","typeGuard":null,"tryCatchPattern":"try {\n    shellTask.handle(callBack);\n} catch (TaskException e) {\n    log.error(\"shell task failed\", e.getCause()); // inspect wrapped cause\n}","preventionTips":["Keep the worker exec/temp directories writable by the worker OS user and monitor free disk space","Include the worker user in your deployment checks","Always log/print the wrapped cause to find the real failure before changing config"],"tags":["shell","task-execution","io"],"backgroundTag":"task-execution-failed","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}