[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Script to build system information. Guru needed :)



On Tue, Dec 21, 2004 at 06:30:35PM +0100, Bob Alexander wrote:
> Slowly building my "disaster assurance" strategy on top of the file backups.
> 
> Amongst other things I want to periodically run a shell script that 
> would build a file with useful information. Here it is:
> 
> lsmod
> lspci
> dpkg --get-selections
> sudo fdisk -l /dev/hda
> df
> uname -a
> 
> Now the questions:
> 
> 1) Other useful commands I am not thinking about ?

`cfdisk -P' will print some more info on the partitions than
fdisk. The following is useful in my case and prints various info on
my three hard disks. See the man page for cfdisk.

for i in a b c; do cfdisk -P rst /dev/hd$i; done

> 2) I would like to redirect the output to a file called with the 
> catenation of 'uname -n'.'uname -r'.config.YYYYMMDDHHMM.txt where 
> YYYYMMDDHHMM is a timestamp of the command execution time. How do I 
> obtain such value ? How do I create the required backticks on my laptop 
> keyboard (no separate numpad)

$(command) was already mentioned as an alternative. But are you sure
the backtich isn't around somewhere? In my case it isn't on the numpad
at all, it is on the same key as the tilde (~). But of course keyboard
can vary wildly.

> 3) If I use cron to run this everyday, being this a laptop client, will 
> the due command be executed if it's natural time has expired ?

You mean: what happens if the laptop is turned off by the time the
command is scheduled to run? Look at package anacron.

> 4) What is the easiest way to keep the last N versions of such files ?

Look at the logrotate package.

Or look at the manual for cp: cp --backup=numbered. And build a small
script around that.

You might put it in an version control system (cvs, subversion, ...)
so you can more easily see all differences over time.

-- 
Maurits van Rees | http://maurits.vanrees.org/ [Dutch/Nederlands] 
Public GnuPG key: keyserver.net ID 0x1735C5C2
"Let your advance worrying become advance thinking and planning."
 - Winston Churchill

Attachment: signature.asc
Description: Digital signature


Reply to: