【问题标题】:Run crontab job with P4使用 P4 运行 crontab 作业
【发布时间】:2018-05-05 17:16:13
【问题描述】:

我有一个 shell 脚本,它又调用了一个 python 脚本。但在 python 脚本运行之前,我正在设置环境变量以便获得正确的 P4 配置。

shell: /home/ag/ump_prod/run.sh
python script: /home/ag/ump_prod/cron.py
Environment conf: /home/ag/ump_prod/env.conf

python 脚本通过 subprocess 模块执行命令行 P4 命令。 这是shell脚本的代码

#!/bin/sh
. /home/ag/ump_prod/env.conf
python /home/ag/ump_prod/cron.py

env.conf

export SHELL=/bin/bash
export USER=ag
export MAIL=/var/mail/ag
export HOME=/home/ag
export LOGNAME=ag
export P4CONFIG=/home/ag/ump_prod/.perforce

perforce 配置 /home/ag/ump_prod/.perforce :

P4CLIENT=ag_ump
P4EDITOR=/usr/bin/vim
P4PORT=rsh:ssh -2 -q -a -x -l p4server p4.****.com /bin/true
P4USER=ag

手动运行 shell 脚本可以毫无问题地执行它。 但是,当我通过 cronjob 运行它时,它会抱怨它无法连接到服务器。

错误信息:

['TCP receive failed.\n', 'read: socket stdio: Connection reset by peer\n', 'Perforce client error:\n', '\tTCP receive failed.\n', '\tread: socket stdio: Connection reset by peer\n']

请让我知道在为 P4 配置设置环境变量时可能出错的地方。提前致谢!

【问题讨论】:

    标签: python linux shell cron perforce


    【解决方案1】:

    我找到了解决方案:我还需要为 cronjob 动态启动 ssh-agent。就像您第一次登录并启动 ssh-agent 一样。我们也需要告诉 cronjob 包含 eval ssh-agent

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-21
      • 2020-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-16
      • 2014-05-07
      • 1970-01-01
      相关资源
      最近更新 更多