Newb needs help with perl script in linux

Newb needs help with perl script in linux

am 03.01.2007 21:52:48 von Romz169

i have a script that does backups of a system. It names the files with
that date on it.

DATE=% (/bin/date +%m-%d-%Y)

tar zcvf /data /backup/%DATE.backup.tgz


Now that works fine, but what i need to do now is put some logic into
it.

if (du -h /backup/"file for yesterday" > "10G")
then
rm /backup/"file for 3 days ago"
fi

Basicly i dont know how to write it at all and i need help. I want it
to look at the file from yesterday and see if it is larger then 10 gig.
If it is i want it to delete the backup from 3 days ago.

Thanks for the help

Re: Newb needs help with perl script in linux

am 03.01.2007 22:25:16 von Jim Gibson

In article <1167857568.664368.28160@s34g2000cwa.googlegroups.com>,
<"Romz169@gmail.com"> wrote:

> i have a script that does backups of a system. It names the files with
> that date on it.
>
> DATE=% (/bin/date +%m-%d-%Y)
>
> tar zcvf /data /backup/%DATE.backup.tgz
>
>
> Now that works fine, but what i need to do now is put some logic into
> it.
>
> if (du -h /backup/"file for yesterday" > "10G")
> then
> rm /backup/"file for 3 days ago"
> fi
>
> Basicly i dont know how to write it at all and i need help. I want it
> to look at the file from yesterday and see if it is larger then 10 gig.
> If it is i want it to delete the backup from 3 days ago.

You are asking your question in a Perl group, but it doesn't appear as
if you are using Perl. Are you asking how to do this job in Perl? I
would consider using the file test operator -s to get the size of the
file, the -M file test operator to get the age of the file in days, and
the File::Find module to find all relevant files.

If you are using a shell program, the find command can look for files
by size (-size) and age (-mtime). Unfortunately, the -size test looks
for a specific size, not a size-greater-than.

What language do you want to use?

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Re: Newb needs help with perl script in linux

am 03.01.2007 22:42:41 von Romz169

good point. i never looked at it that closely, I did not write the
script and the guy that did is a perl programer but it turns out it is
written in as a shell script. I am not to good with programming at all.
The person who did this work left and i happen to be the most
knowledgeable in linux so i have to support our linux boxes. The script
indicated here requires constant manintance due to disk space. The
backups are very large and take up alot of space. Im just trying to put
some logic in the script so i dont have to do it manualy.

I have posted it in a different group now, but if you have any
information that would help id apprecate it.

Jim Gibson wrote:
> In article <1167857568.664368.28160@s34g2000cwa.googlegroups.com>,
> <"Romz169@gmail.com"> wrote:
>
> > i have a script that does backups of a system. It names the files with
> > that date on it.
> >
> > DATE=% (/bin/date +%m-%d-%Y)
> >
> > tar zcvf /data /backup/%DATE.backup.tgz
> >
> >
> > Now that works fine, but what i need to do now is put some logic into
> > it.
> >
> > if (du -h /backup/"file for yesterday" > "10G")
> > then
> > rm /backup/"file for 3 days ago"
> > fi
> >
> > Basicly i dont know how to write it at all and i need help. I want it
> > to look at the file from yesterday and see if it is larger then 10 gig.
> > If it is i want it to delete the backup from 3 days ago.
>
> You are asking your question in a Perl group, but it doesn't appear as
> if you are using Perl. Are you asking how to do this job in Perl? I
> would consider using the file test operator -s to get the size of the
> file, the -M file test operator to get the age of the file in days, and
> the File::Find module to find all relevant files.
>
> If you are using a shell program, the find command can look for files
> by size (-size) and age (-mtime). Unfortunately, the -size test looks
> for a specific size, not a size-greater-than.
>
> What language do you want to use?
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
> http://www.usenet.com

Re: Newb needs help with perl script in linux

am 04.01.2007 11:18:55 von Joe Smith

Jim Gibson wrote:

> If you are using a shell program, the find command can look for files
> by size (-size) and age (-mtime). Unfortunately, the -size test looks
> for a specific size, not a size-greater-than.

Not true.

find . -size -10G -print > less-than-10.0000G
find . -size 10G -print > 10.0000G-to-10.9999G
find . -size +10G -print > more-than-10.9999G