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.

Monday, June 11, 2012

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

SkyHi @ Monday, June 11, 2012
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`" < /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"
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"
Display locale’s 12-hour clock time
$ date +"%r"
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:
NOW=$(date +"%m-%d-%Y")
# 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 %

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

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

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

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

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

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

day of month, space padded; same as %_d

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

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

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

same as %b
hour (00..23)

hour (01..12)

day of year (001..366)

hour ( 0..23)

hour ( 1..12)

month (01..12)
minute (00..59)

a newline

nanoseconds (000000000..999999999)

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

like %p, but lower case

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

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

second (00..60)

a tab

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

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

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

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

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

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

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


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

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

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

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

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

See also: