You are on page 1of 2

script backup database MySQL nh sau:

#!/bin/bash
DB=db_gocit_bk_`date +%Y%m%d-%H%M`.sql

/usr/bin/mysqldump -u root --password='password_gocit' --
databases gocit -R > /backup/database/$DB
gzip /backup/database/$DB

Sau cho script ny chy nh k vo 4h sng hng ngy
bng cch to mt file crontab nh sau:

# crontab -e

4 0 * * * /bin/sh /backup/backup.sh >/dev/null

Cui cng, nh kim tra dch v cron daemon

# /etc/init.d/crond status

Nu crontab cha khi ng th khi ng bng lnh

# /etc/init.d/crond start

# chkconfig crond on

Trch http://www.gocit.vn/bai-viet/crontab-linux/

You might also like