[Tutor] Simple Linux Admin1, New guy looking for some tips.

Alan Gauld alan.gauld at blueyonder.co.uk
Sat Feb 7 16:15:00 EST 2004


> Example:........(And I know that this can be done very
> simply using other means besides Python)

As an exercise for learning Python its fine but a simple shell
script will be much more effective for this type of thing IMHO.

> ...
>Since these logs are "only occasionally" used for referencing I would
> like to compress all the log files in this directory when seen fit
and
> have a subdirectory created in the "parent portage" directory to
store
> compressed files. Kinda like a "Portage log Archive" I guess.

This is usually done more easily using a tar file.
In fact so comon is it that tar takes a flag to force compression
of the resultant archive. So something like this will do it...

#! /usr/sh
# archive files and compress the result
# add some input checking and a usage message here
tar -gzf $1 $#
echo "archived " $1

> So hopefully the following is a good starting baby step to
> learning some Python.  :P

But as a learning exrise its good and there are lots of admin
type tools to learn.

Go study the os, path, glob, tar and gzip modules.

> #My Mental note: I would preferably like to compress
> all files together if possible instead of individually.

Usually thats done by tar followed by gzip (or bzip2) or
more simply by justvspecifying the z flag to tar...

> How do I do this with Python considering "#My Mental note:"?
> I will use this example as a building point instead of jumping
> into the wxPython

For sys admin things GUIS are mostly redundant.

Generally you should write a script then put it in your cron
file to run automatically. If you have a standard approach to
errors you can even write a cron job to check for errors and
send you an email to alert you to failed jobs...

Alan G.




More information about the Tutor mailing list