Bash Script para backup de todas las bases de MySQL


USER=”super usuario”
PASSWORD=”ingrese la clave aquí”

rm “$OUTPUT/*gz” > /dev/null 2>&1

databases=`mysql –user=$USER –password=$PASSWORD -e “SHOW DATABASES;” | tr -d “| ” | grep -v Database`

for db in $databases; do
if [[ “$db” != “information_schema” ]] && [[ “$db” != _* ]] ; then
echo “Dumping database: $db”
mysqldump –force –opt –user=$USER –password=$PASSWORD –databases $db > $OUTPUT/`date +%Y%m%d`.$db.sql
gzip $OUTPUT/`date +%Y%m%d`.$db.sql

How to clean /tmp on Centos/cPanel server | Limpiar /tmp en un servidor CentOS

How to clean /tmp on Centos/cPanel server

open SSH to your server, if SSH will not connect due to disk space full in tmp, reboot your server in cloud server manager then try again.
Once connected run the following command

yum install tmpwatch -y

once tmpwatch is installed run command

/usr/sbin/tmpwatch -am 12 /tmp

this will delete all files over 12 hours old

next, we will configure your server to do this automatically.

from SSH type:  crontab -e

go to the very bottom and paste

0 4 * * * /usr/sbin/tmpwatch -am 12 /tmp

then press Control+X (on PC) or Command+x (on Mac) you will get confirmation do you want to save. Type Y for yes, and press enter.

The Location for the corntab for root ,    /var/spool/cron  so you can add the line by using CSE

You can remove session file using following command.

# cd /tmp
# rm -rf sess_*