Wednesday, June 13, 2012

How To Shrink A Giant Outlook PST File

SkyHi @ Wednesday, June 13, 2012

Periodically, I shrink my Outlook PST file. For one reason, it’s easier to back it up manually from time to time when it’s smaller. For another, I guess I feel things just run better when it’s small and tidy.
Today, I shrank my file from over 1.1 GB to 80MB, a pretty drastic reduction. Being excited about such things, I tweeted it, which resulted in a bunch of people asking how. So here are my how make your Outlook PST files smaller tips!
1) Delete sent mail. But wait, you want to save that sent mail? Two options:
1A) Archive via Gmail or another hosted email system, so that you have a permanent online archive of anything you’ve emailed. See my Moving From SpamCop To Gmail & Loving POP Download With Archiving for more about this.
1B) Make additional PST files and move mail into these. For example, I have two PST files active. One is my main file called Danny, which is where my current mail resides. The other is called Archive, where I have a 2008 folder within it:
Archive Folder
Over the course of 2009, I’ve periodically taken email that I want to have a local backup of and copied from the “Sent Items” folder in my Danny PST file over to the 2008 Mail folder within the Archive PST file.
Down the line, I’ll make another PST file called 2008. My 2008 Mail folder will get moved into into that. I’ll then detach the 2008 PST file and save in case I ever need it. I have a series of these for each year. Meanwhile, my Archive PST file remains as an active holding place for mail. It’ll gain a new 2009 Mail folder.
2) Empty Deleted Items Folder. Yes, even though you deleted that email, it’s still sitting around in your Deleted Items folder making your PST file bigger until you really delete it. Do that by right clicking on the folder, then selecting the Empty option:
Deleted Items Folder
I usually only keep about 1 month’s worth of deleted mail at a time, just in case I need to go back and find something locally (such as when I’m on a airplane).
3) Compress! Right click on your PST file (not the folders within it, but the main file itself as listed in the navigation pane. Then select Properties:
PST Properties
A new window will appear, your Outlook Today window. Select Advanced, which makes your Personal Folders window appear:
Compact Outlook PST
Choose Compact Now. Sit back and get something to drink. In about 10 minutes or so, depending on the size of your PST file, it will be dramatically reduced in size.
Why go through all this hassle. Why not just use Gmail directly? Short story is that Outlook’s a fantastic email management program. Long story is for a future post, where I detail why I like using both Outlook and Gmail together.
REFERENCES

Monday, June 11, 2012

How to format date for display or to use in a shell script

SkyHi @ Monday, June 11, 2012
#!/bin/sh
echo "[potato2/check_relay] $HOSTNAME - `date` " > /tmp/.check_relay.txt
grep 'check_relay' /var/www/Sendmaillog/maillog |grep "`date "+%b %d"`"| awk '{print $7}'|sort | uniq -c |sort -nr >> /tmp/.check_relay.txt
head -500 /tmp/.check_relay.txt  > /tmp/.check_relay.txt

mail -s "[potato/check_relay] $HOSTNAME - `date`" admin@example.com < /tmp/.check_relay.txt



Q. How do I format date to display on screen on for my scripts as per my requirements?
A. You need to use standard date command to format date or time for output or to use in a shell script.
Syntax to specify format
date +FORMAT

Task: Display date in mm-dd-yy format

Type the command as follows:
$ date +"%m-%d-%y"
Output:
02-27-07
Turn on 4 digit year display:
$ date +"%m-%d-%Y"
Just display date as mm/dd/yy format:
$ date +"%D"

Task: Display time only

Type the command as follows:
$ date +"%T"
Output:
19:55:04
Display locale’s 12-hour clock time
$ date +"%r"
Output:
07:56:05 PM
Display time in HH:MM format:
$ date +"%H-%M"

How do I save time/date format to a variable?

Simply type command as follows at a shell prompt:
$ NOW=$(date +"%m-%d-%Y")
To display a variable use echo / printf command:
$ echo $NOW
Sample shell script:
#!/bin/bash
NOW=$(date +"%m-%d-%Y")
FILE="backup.$NOW.tar.gz"
# rest of script

Complete list of FORMAT control characters supported by date command

FORMAT controls the output.It can be the combination of any one of the following:

%%

a literal %
%a

locale's abbreviated weekday name (e.g., Sun)
%A
locale's full weekday name (e.g., Sunday)
%b

locale's abbreviated month name (e.g., Jan)
%B

locale's full month name (e.g., January)
%c

locale's date and time (e.g., Thu Mar 3 23:05:25 2005)
%C

century; like %Y, except omit last two digits (e.g., 21)
%d

day of month (e.g, 01)
%D
date; same as %m/%d/%y
%e

day of month, space padded; same as %_d
%F

full date; same as %Y-%m-%d
%g

last two digits of year of ISO week number (see %G)
%G

year of ISO week number (see %V); normally useful only with %V
%h

same as %b
%H
hour (00..23)
%I

hour (01..12)
%j

day of year (001..366)
%k

hour ( 0..23)
%l

hour ( 1..12)
%m

month (01..12)
%M
minute (00..59)
%n

a newline
%N

nanoseconds (000000000..999999999)
%p

locale's equivalent of either AM or PM; blank if not known
%P

like %p, but lower case
%r

locale's 12-hour clock time (e.g., 11:11:04 PM)
%R
24-hour hour and minute; same as %H:%M
%s

seconds since 1970-01-01 00:00:00 UTC
%S

second (00..60)
%t

a tab
%T

time; same as %H:%M:%S
%u

day of week (1..7); 1 is Monday
%U
week number of year, with Sunday as first day of week (00..53)
%V

ISO week number, with Monday as first day of week (01..53)
%w

day of week (0..6); 0 is Sunday
%W

week number of year, with Monday as first day of week (00..53)
%x

locale's date representation (e.g., 12/31/99)
%X

locale's time representation (e.g., 23:13:48)
%y
last two digits of year (00..99)
%Y

year
%z

+hhmm numeric timezone (e.g., -0400)
%:z

+hh:mm numeric timezone (e.g., -04:00)
%::z

+hh:mm:ss numeric time zone (e.g., -04:00:00)
%:::z

numeric time zone with : to necessary precision (e.g., -04, +05:30)
%Z

alphabetic time zone abbreviation (e.g., EDT)

See also:


REFERENCES