【发布时间】: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