Archive

Archive for the ‘Scripting’ Category

Automated DVD Backup

May 31st, 2009 1 comment
Print Friendly, PDF & Email

Today I would like to share with you, a little script that I use every week. I have four rewritable DVD that I use in rotation to backup important directories of my server at home. All I have to do is to leave one of these DVD+RW in the dvd drive and a backup of my important directories will be taken at regular interval. I have schedule a cron job that run tree times a week, to backup to DVD directories that are important to me. This is by no way a replacement of a full system backup like Mondo rescue, Storix or Acronis, but they represent to me the directories that are subject to change more often. I must specify that the command used in this script require using a DVD+RW to work.

Read more…

Categories: Scripting

Doing more with less

April 18th, 2009 No comments
Print Friendly, PDF & Email

We usually use the “less” command to browse the content of a text file. We use the [Page-Up], [Page-Down], [Down-Arrow], [Up-Arrow] keys to move within the file, but did you know that you can do more with the less command ?

You can see the content of a rpm file

# less flash-plugin-9.0.124.0-release.i386.rpm
 Name        : flash-plugin                 Relocations: (not relocatable)
 Version     : 9.0.124.0                    Vendor: Adobe Systems Inc.
 Release     : release                      Build Date: Tue 25 Mar 2008 12:21:32 PM EDT
 Install Date: (not installed)              Build Host: fplayerbuild2-lnx.macromedia.com
 Group       : Applications/Internet        Source RPM: flash-plugin-9.0.124.0-release.src.rpm
 Size        : 8161247                      License: Commercial
 Signature   : (none)
 Packager    : Adobe Systems Inc.
 URL         : http://www.adobe.com/downloads/
 Summary     : Adobe Flash Player 7.0
drwxr-xr-x     2 root    root        0 Mar 25  2008 /usr/lib/flash-plugin
 -rw-r--r--    1 root    root    34516 Mar 24  2008 /usr/lib/flash-plugin/LICENSE
 -rw-r--r--    1 root    root     3180 Mar 24  2008 /usr/lib/flash-plugin/README
 -rwxr--r--    1 root    root     1367 Mar 24  2008 /usr/lib/flash-plugin/homecleanup
 -rwxr-xr-x    1 root    root   115888 Mar 25  2008 /usr/lib/flash-plugin/libflashplayer.so
 -rwxr--r--    1 root    root     3116 Mar 24  2008 /usr/lib/flash-plugin/setup
 drwxr-xr-x    2 root    root        0 Mar 25  2008 /usr/share/doc/flash-plugin-9.0.124.0
 -rw-r--r--    1 root    root     3180 Mar 25  2008 /usr/share/doc/flash-plugin-9.0.124.0/readme.txt
 (END)

View the content of zip file :

$ less StudioPress.zip
Archive:  StudioPress.zip   196759 bytes   42 files
drwxr-xr-x  2.3 unx        0 bx stor 17-Sep-08 09:05 StudioPress/
-rw-r--r--  2.3 unx     3848 tx defN 14-Jan-08 09:05 StudioPress/comments.php
-rw-r--r--  2.3 unx      231 tx defN 14-Jan-08 09:05 StudioPress/searchform.php
-rw-r--r--  2.3 unx      169 tx defN  4-Feb-08 09:44 StudioPress/adsense_top.php
-rw-r--r--  2.3 unx     1393 tx defN  5-Feb-08 06:50 StudioPress/home.php
-rw-r--r--  2.3 unx     1411 tx defN 14-Jan-08 09:05 StudioPress/functions.php

View the content of tar or tgz file

$ less update_inv.tar
drwxr-xr-x jacques/jacques   0 2008-01-03 20:48:50 update_inv/
drwxr-xr-x jacques/jacques   0 2008-03-22 13:52:07 update_inv/log/
-rw-rw-r-- jacques/jacques   0 2008-03-22 13:52:07 update_inv/log/update_inv.log
drwxr-xr-x jacques/jacques   0 2008-03-22 13:52:33 update_inv/html/
-rw-rw-r-- jacques/jacques 941 2008-03-26 19:24:51 update_inv/html/gumby.html
drwxr-xr-x jacques/jacques   0 2008-03-22 13:52:07 update_inv/tmp/
-rwxrwxr-x jacques/jacques  19059 2008-03-26 19:00:43 update_inv/update_inventory.py
update_inv.tar (END)
Categories: Scripting

Epoch time date calculation

April 8th, 2009 No comments
Print Friendly, PDF & Email

In the Unix/Linux world we always come across at one point with the term “epoch time”. The epoch time is actually the number of seconds elapsed since midnight of January 1, 1970. Some application record the date and time in “epoch time”. Squid proxy server, for an example will record date and time entries in its log in epoch time.

I think we will all agree, that working with this kind of date format is not very meaningful for us. So, if you ever need to convert an epoch time format to a more readable format, here are some example using the bash shell.

Convert epoch time to date format

# date -d @1221256800 "+%Y-%m-%d %T"
 2008-09-13 00:00:00

Convert date to epoch time

# date -d "20080913" +%s"
 1221256800
Categories: Scripting