【问题标题】:psql: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directorypsql:加载共享库时出错:libpq.so.5:无法打开共享对象文件:没有这样的文件或目录
【发布时间】:2017-04-06 16:23:14
【问题描述】:

我的路径变量中有 psql 路径。 crontab 路径是usr:/usr/bin:/bin 我添加所有用户目录,然后执行 cron 作业。

Default PATH for usr:/usr/bin:/bin
user is:gpadmin
PATH for usr:/usr/bin:/bin:/usr/local/greenplum-db/./bin:/usr/local/greenplum-db/./ext/python/bin:/home/gpadmin/anaconda3/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/home/gpadmin/bin

我的脚本如下(由crontab执行):

#!/bin/bash
# Usage : bash RR_load.sh

echo "Loading the data into datalake"
now="$(date +'%d-%m-%Y')"
basedir="/home/2125/RR_Dev_Code"

#echo "load started at $now"
#logname=$0"_"$now".log"
ts="$(date +'%d-%m-%Y_%H:%M:%S')"
echo "load started at $ts"
echo `who am i`
logname=$0"_"$ts".log"
echo "load started at $ts" > $logname
chmod 777 $logname
nohup python $basedir/copy_csv_to_data_lake_v3.py $basedir >> $logname
echo "process id $!" >> $logname
echo "Recreate the table using loader.sh"
echo "Default PATH for usr:"$PATH >> $logname
export PATH=$PATH:/usr/local/greenplum-db/./bin:/usr/local/greenplum-db/./ext/python/bin:/home/gpadmin/anaconda3/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/home/gpadmin/bin
source /etc/profile
psql -h '3.48.35.24' -U 'tan12345' 'sourcing' << EOF
Select current_timestamp(0);
EOF

在按计划执行时,我在/var/spool/mail/gpadmin 中看到如下消息:

Loading the data into datalake
load started at 06-04-2017_12:19:01

dos2unix: converting file /home/2125/RR_Dev_Code/sandbox-rr_data.2017-03-29.csv to UNIX format ...
Recreate the table using loader.sh
psql: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory

【问题讨论】:

  • 你的来源是 /usr/local/greenplum-db/greenplum_path.sh 吗?
  • @JonRoberts 感谢您的建议。我也会试试这个。在命令之前添加 .bash_profile 解决了我的问题

标签: cron psql greenplum


【解决方案1】:

在 crontab 中的命令前添加了 .bash_profile。

# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed

# test entry
#* * * * * echo `whoami`  > /home/2125/RR_Dev_Code/ETL/crontab.test
59 13 * * 4 . $HOME/.bash_profile;/home/2125/RR_Dev_Code/RR_load_v3.sh

感谢您在此处发布的答案: https://unix.stackexchange.com/questions/27289/how-can-i-run-a-cron-command-with-existing-environmental-variables.

现在看到所有艰苦的工作都自动运行,真是一种解脱。

【讨论】:

    【解决方案2】:

    我正在添加第二个答案,以防万一有人想使用另一种方法而不是已经选择的答案。 Jon Roberts 提出的解决方案效果很好。

    只需运行:“source /usr/local/greenplum-db/greenplum_path.sh”

    干杯

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-07
      • 2018-07-18
      • 2021-02-11
      • 1970-01-01
      • 2019-02-16
      • 2015-10-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多