簡體   English   中英

使用P4運行crontab作業

[英]Run crontab job with P4

我有一個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腳本通過子過程模塊執行命令行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配置設置環境變量時可能出錯的地方。 提前致謝!

我找到了解決方案:我還需要為cronjob動態啟動ssh-agent。 就像您第一次登錄並啟動ssh-agent一樣。 我們也需要告訴cronjob包括eval ssh-agent

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM