Oct 21

Here’s an easy way to change the prompt in Unix Shell

export PS1="[\W]$ "

This will use the current directory as command prompt

Tagged with:
Nov 09

When you write a shell scripts you need to create filename with date in it. For example instead of log file name “bauson.log”, you can create a filename called “jan-02-06-bauson.log”.

The date in file will make it easy to find out all logs or reports. You can display the current date and time in the given FORMAT using date command. If you just type date command it will display in standard FORMAT:

$ date
Output:
Mon Nov 9 10:54:57 PHT 2009

To display date in MONTH-DAY-YEAR format you need to use date command as follows:

$ date +"%b-%d-%y"

Nov-09-09

As you can see I have used FORMAT as follows
date +”FORMAT”
Where, FORMAT can be any one of the following:

  • %a : Abbreviated weekday name (Sun..Sat)
  • %b : Abbreviated month name (Jan..Dec)
  • %B : Full month name, variable length (January..December)
  • %d : day of month (01..31)
  • %e : day of month, blank padded ( 1..31)
  • %H : 24 hour format (00..23)
  • %I : 12 hour format (01..12)
  • %j : day of year (001..366)

First obtained date:

$ NOW=$(date +"%b-%d-%y")

Create a file with date in filename:

$ LOGFILE="$NOW-bauson.log"

Display Filename

$ echo $LOGFILE

Usage:

10 7 * * * NOW=$(date +"%b-%d-%y"); LOGFILE="$NOW-bauson.log"; php my.php >log/$LOGFILE
Tagged with:
Aug 27

I found mysql tuning is a pain. This script is a good tool to adjust your mysql variables. It evaluates the following variables:

slow query count
long_query_time
query_cache_size
% query cache actually used
max_connections
thread_cache
key_buffer_size
ratio of sort_merge operations to sorts (sort_buffer_size)
number of full joins
ratio of disk tmp tables vrs in memory tmp tables (tmp_table_size)
table_cache
ratio of table locks immediate to table locks waited
ratio of table scans (read_buffer_size)

MySQL Tuner

To use the script add your user name and password to a [client] group in your ~/.my.cnf file

Tagged with:
preload preload preload
Bless CV