Linux定时脚本

切换到相应目录

cd /home/pgbackups/

创建脚本文件

touch pgbackups.sh

编辑自动化脚本

#! /bin/bash
/home/postgres/pgsql/bin/pg_dump -h 10.8.87.7 -p 5478 -U postgres --column-inserts wechart > /home/pgbackups/wechartdb`date +%Y%m%d`.sql

打开自动化脚本编辑

crontab -e

编辑自动运行(每天5点半执行)

30 5 * * * /home/data/pgbackups.sh > /home/data/logs 

你可能感兴趣的:(Linux定时脚本)