Archive for the ‘Linux’ Category

Installing the DBT2 Benchmark Tool on Linux

Just recording the process I used to install the DBT2 bench-marking tool. I used OpenSuSE 12.1 for this but should work on many distributions. ?View Code BASHcd /opt/src wget http://downloads.mysql.com/source/dbt2-0.37.50.3.tar.gz tar xvf dbt2-0.37.50.3.tar.gz cd dbt2-0.37.50.3/ ./configure –with-mysql make make install Don’t forget to read the documentaiton to start running MySQL benchmarks… cat README-MYSQL

Migrate users between MySQL Servers with pt-show-grants

If you use MySQL but don’t use Percona Toolkit you’re really missing a trick. It contains a whole host of useful tools including pt-show-grants which I use to migrate users between servers easily. ?View Code BASHpt-show-grants –host mysqlservername –user username –password secret | mysql -h localhost -u username -p If you want to filter out any [...]

Monitor /tmp usage on Linux

Just a quick post to show how to monitor usage of /tmp on a Linux system. Setup a cron job as follows… ?View Code BASH* * * * * df -h | grep "/tmp" >> /tmp/tmp.log This job will run every one minute logging details of /tmp usage to a file called tmp.log. To report [...]

Linux Tip: Output error messages to syslog from cron

I wanted to find a way of running a script in cron and output the exit code, and error message, to syslog if it failed. Here’s what I came up with… ?View Code BASHoutput=`/usr/bin/scripts/test.sh 2>&1`; code=$?; if [ "$code" -ne 0 ]; then err_msg=`echo "$output" | tail -1`; logger -t "CRONERROR" "Exit Code = $code: [...]

Linux Tip: Add datetime stamp to bash history

I like to know what’s happening on my Linux servers. The output of the history command doesn’t include a datetime stamp by default.  To rectify this open the global profile…. ?View Code BASHvi /etc/profile Add the following line to the bottom. ?View Code BASHexport HISTTIMEFORMAT="%h %d %H:%M:%S " The output of the history command will [...]