标签:select man 设置 psql echo centos script manual yellow
# echo ‘PATH=/opt/opsmgr/web/components/postgresql96linux64.1/bin/:$PATH‘ >> /etc/profile
# echo ‘export PGPASSWORD=ytcmUUNq‘ >> /etc/profile
# cat update.sh
#!/bin/bash
source /etc/profile
Date=$(date +%Y%m%d)
Cmd="/create/d"
Sql="create table test_bak$Date as select * from test;"
Sqlfile=‘/opt/opsmgr/web/components/postgresql96linux64.1/script/manual/update.sql‘
sed -i "$Cmd" $Sqlfile
sed -i "1i $Sql" $Sqlfile
psql -U vvt_vvtdb_user -d vvt_vvtdb -p 7017 -f $Sqlfile
# cat update.sql
create table vvt_violation_vehicle_pass_bak as select * from vvt_violation_vehicle_pass;
update vvt_violation_vehicle_pass set plate_type_gb=‘02‘ where plate_color=‘blue‘ and plate_type_gb= ‘99‘;
update vvt_violation_vehicle_pass set plate_type_gb=‘01‘ where plate_color=‘yellow‘ and plate_type_gb= ‘99‘;
# echo "00 22 * * * /opt/opsmgr/web/components/postgresql96linux64.1/script/manual/update.sh" > /var/spool/cron/root
# crontab -l //查看计划任务
00 22 * * * /opt/opsmgr/web/components/postgresql96linux64.1/script/manual/update.sh
centos7系统通过crontab定时向pg数据库执行命令
标签:select man 设置 psql echo centos script manual yellow
原文地址:https://www.cnblogs.com/ly447742/p/14765733.html