Wednesday, July 25, 2012

Redirect apache


cat /usr/local/httpd/htdocs/index.html





Monday, August 15, 2011

grep date in filename

$ ls | egrep staff-list-[0-9]{2}-[A-z]{3}-[0-9]{4}.csv
staff-list-22-aug-2011.csv

Wednesday, August 10, 2011

MySQL get Start(Sunday) and End(Saturday) of week for a given date

select subdate(date('2011-08-06'), INTERVAL dayofweek(date('2011-08-06')) DAY) as StartOfWeek, adddate(date('2011-08-06'), INTERVAL 7-dayofweek(date('2011-08-06')) DAY) as EndOfWeek;
select subdate(date('2011-08-07'), INTERVAL dayofweek(date('2011-08-07')) DAY) as StartOfWeek, adddate(date('2011-08-07'), INTERVAL 7-dayofweek(date('2011-08-07')) DAY) as EndOfWeek;
select subdate(date('2011-08-13'), INTERVAL dayofweek(date('2011-08-13')) DAY) as StartOfWeek, adddate(date('2011-08-13'), INTERVAL 7-dayofweek(date('2011-08-13')) DAY) as EndOfWeek;

Monday, July 11, 2011

Extract single table from gzipped mysqldump file.

# with drop and create statements
$ zcat event_tables_prod1.sql.gz | sed -n "/^-- Table structure for table \`WEEKLY_EXCEPTION_REPORT\`/,/^-- Table structure for table/p" >
# without drop and create statements
$ zcat event_tables_prod1.sql.gz | sed -n "/^-- Dumping data for table \`WEEKLY_EXCEPTION_REPORT\`/,/^-- Dumping data for table /p" > exceptions_only_prod1.sql

Wednesday, April 13, 2011

Fix Corrupt relay logs

Master_Log_File: The name of the master binary log file from which the I/O thread is currently reading.
Relay_Log_File: The name of the relay log file from which the SQL thread is currently reading and executing.

Relay_Master_Log_File: The name of the master binary log file containing the most recent event executed by the SQL thread.


-- The status below is most often cause by network connection between slave and master being dropped while slave while slave is reading master's binary log to create the relay log.
-- The "Last_error:" message states that it could be master binary or slave relay log corruption. It is usually slave relay corruption because it is much easier to corrupt this log.

Friday, April 1, 2011

mysql dump over ssh

mysqldump -uroot -p epictide events quartz | gzip -c | ssh michaelfw@128.147.97.132 'cat > ~/dump.sql.gz'

Monday, March 14, 2011

bash sleep 45 - 60 seconds.

$ number=0
$ let number="$RANDOM % 15 + 45"
$ sleep $number