You See Our Blogs!
See & Xplorer Our Blogs!

Bash script::delete table mysql + cron

Cyd! kembali little2 membuat bash script di linux. Fungsi ini diterapkan untuk menghapus rekaman pada table di Mysql secara berkala. Cyd! menerapkan setiap hari ke-14 isi data dihapus pada table1. Berikut script tsb. Blogs readers Cyd! simpan script tsb pada file, contoh deltable1.sh (chmod 755 & simpan di /usr/bin/)

!/bin/bash
user=”dbuser”
pass=”dbpassword”
host=”dbhost”<– biasanya localhost
mysql -u $user -p$pass $db -h $host -e “use db1; delete from table1;”
exit 0

dan berikut ini script dijalankan oleh cron

* 17 21 * * /usr/bin//usr/bin/deltable1.sh

Keterangan cron : setiap jam 17:00 dihari ke-14

 

Cyd!

Advertisement

No Responses to “Bash script::delete table mysql + cron”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.