Tag: BASH

  • Drop all MySQL DBs (except mysql & information_schema)

    For some reason I can not remember the following command. I have been using it a lot lately when testing MySQL replication. mysql –skip-column-names –batch -e “show databases” | grep -E -v “mysql|information_schema” | xargs -I “@@” mysql -e “drop database @@” This will drop all DBs except the default mysql and information_schema dbs. Then…

  • Script to compare RPMs on two different CentOS servers

    I wanted to make sure that the same RPMs were installed on several servers. I wasn’t worried about versions of RPMs because everything should be kept up to date via yum. So I sat down and wrote the script below. It has been on my ToDo list for quite a while! This script connects to…

  • AutoSSH on CentOS

    I have been interested in MySQL replication over ssh and I wanted a way to make sure that the tunnel is always up. Everyone says to use AutoSSH. AutoSSH is not in EPEL, but is in rpmforge (Is that that same as DAG? Didn’t they merge?). I installed rpmforge: I don’t like to do the…

  • Mirror all MySQL DBs to the local machine

    Continuing on my quest to get MySQL replicating over ssh, I am using the following bash function to replicate all remote DBs locally:   Line 2 connects to the local AutoSSH tunnel and gets a list of all the remote DBs. Then we loop through the DBs and if there is not a DB locally…

  • OS X: Move files based on creation date

    I wanted to organize my flip videos – I wanted them moved into a folder named after their creation date. One of the scripts that I found uses ls’s “–time-style” parameter. BSD’s ls does not have this value. MacPorts’ coreutils port contains gls (GNU’s ls) that does support the parameter. So here is my script…

  • Check if a file exists on a remote server

    I was working on a copy WordPress site to a local machine script, and I wanted to check if the remote path was a WordPress site. Here is the code I used.

  • Waking a sleeping Mac Pro upon opening a folder

    Scenario I have two macs at home, a MacPro and a MacMini. The MacMini is attached to our TV. I put my MacPro to sleep when I leave for work in the morning. My wife comes home and tries to play videos for my son on the Mac Mini. The videos are actually on the…

  • New MD5 based backup script

    I found this use of md5 and find the other day. I based my current backup script around it. The md5 will show if anyone modifies a file, or adds/removes a file in the web hosting root (/var/www) or in the config directory (/etc/httpd/conf.d/). If there is a change then zip each site up individually…

  • BASH (readline) keyboard shortcuts

    I was just in training and the instructor was a command line keyboard shortcut wizard. He was magically making words disappear and reappear. So i fond this list of shortcuts. Many of them did not work in my OS X BASH prompt.I fond I had to go into the terminal.app preferences and select “use option…