March 28, 2011, 10:51 am
I’ve found that when dealing with rrdfiles, they can show the wrong lastmodified time. This means if I go with the usual: delete all files that haven’t been modified within say 2 days, I could be deleting some GOOD rrd files…
Here’s my solution. Use rrdtool lastupdated to spit out epoch time of last updated and anything that’s older than 2 days we’ll delete:
1 2 3 4 5 6 7 8 9 10 11 12
| for myfile in *.rrd
do
#rrdtool lastupdate $myfile | tail -1 | awk -F: '{if ($1 < systime()-172800) print strftime("%c",$1)}';
RETURN=`rrdtool lastupdate $myfile | tail -1 | awk -F: '{if ($1 < systime()-172800) print 0}'`
if [ "$RETURN" == 0 ]; then
echo "Deleting $myfile"
# uncomment to really remove file
#/bin/rm -f $myfile
else
echo "Skipping File $myfile"
fi
done |
March 7, 2011, 11:41 am
Sometimes you need to install Perl Modules in your OWN (non root) directory. Found a great writeup on how to do this:
% perl5 Makefile.PL PREFIX=/usr/home/USERNAME/usr/local
% make
% make test
% make install
% make clean
And then in your perl code you would use this near the top:
use lib qw(/usr/home/USERNAME/usr/local/lib/perl5);
There’s another writeup on using CPAN that didn’t work as well for me:
$ mkdir ~/.cpan
$ mkdir ~/.cpan/CPAN
$ cd ~/.cpan/CPAN
$ cp /usr/lib/perl5/5.8.4/CPAN/Config.pm MyConfig.pm
$ perl -pi -e's!/root/\.cpan!$ENV{HOME}/.cpan!' MyConfig.pm
$ perl -pi -e'/makepl_arg/ && s!\]! PREFIX=$ENV{HOME}]!' MyConfig.pm
$ echo "export PERL5LIB=${HOME}/lib/perl5/site_perl/5.8.4/i686-linux:${HOME}/lib/perl5/site_perl/5.8.4" >> ~/.bash_profile
$ . ~/.bash_profile
$ perl -MCPAN -e shell
cpan> install HTML::Template
March 2, 2011, 5:31 pm
Here’s a great wget trick to download all the Photos of the Day from NASA. There’s some great switches in there I never new existed.
wget -r -l2 -t1 -nd -N -np -w2 -A.jpg -erobots=off http://apod.nasa.gov/apod/archivepix.html
(source lifehacker)