psql:加载共享库时出错:libpq.so.5:无法打开共享库文件:没有这样的文件或目录 [英] psql: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory
问题描述
我的path变量中有psql路径。 crontab路径为 usr:/ usr / bin:/ bin
我添加了所有用户目录,然后执行cron作业。
I have the psql path in my path variable. crontab path is usr:/usr/bin:/bin
I add all the user directories and then execute the cron job.
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执行):
My script is as below (executed by 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
按计划执行时,我在<$ c $中看到一条消息c> / var / spool / mail / gpadmin 如下:
On getting executed as per schedule, I see a message in /var/spool/mail/gpadmin
as below:
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
推荐答案
在crontab中的命令之前添加了.bash_profile。
Added the .bash_profile before the command in crontab.
# .---------------- 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-environmentalvariables 。
Thanks for the answer posted here : https://unix.stackexchange.com/questions/27289/how-can-i-run-a-cron-command-with-existing-environmental-variables.
看到现在自动运行的所有辛勤工作,这真让人感到欣慰。
Such a relief to see all the hard-work running automatically now.
这篇关于psql:加载共享库时出错:libpq.so.5:无法打开共享库文件:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!