bash操作员不运行bash文件需要SUDO权限

2024-09-28 18:55:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个名为CC的脚本,它收集数据并将其推入数据仓库。 我为它创建了一个dag

      Task_I = BashOperator(
        task_id="CC",
        run_as_user="koa",
        bash_command="sudo /home/koa/CC"
      )

我还通过修改/etc/sudoers添加了在不输入密码的情况下运行它的权限

  koa ALL = (ALL) NOPASSWD: /home/koa/CC

但是,当任务失败时,日志会说明需要密码

{bash_operator.py:146} INFO - Running command: sudo /home/koa/CC 
{bash_operator.py:153} INFO - Output:
{bash_operator.py:157} INFO - sudo: a terminal is required to read 
 the password; either use the -S option to read from standard input or configure an askpass 
 helper
{bash_operator.py:159} INFO - Command exited with return code 1

伙计们,如果你们能帮我的话,那就太好了。我对气流还不熟悉,在过去的几个小时里一直在努力解决这个问题


Tags: thetopyinfo脚本bash密码home