Gentoo Archives: gentoo-user

From: Tanstaafl <tanstaafl@×××××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] "rm: missing operand" in emailed result of cron job that uses rm to remove aged files
Date: Mon, 20 Jan 2014 12:38:10
Message-Id: 52DD1887.30802@libertytrek.org
In Reply to: Re: [gentoo-user] "rm: missing operand" in emailed result of cron job that uses rm to remove aged files by Neil Bothwick
1 On 2014-01-20 6:51 AM, Neil Bothwick <neil@××××××××××.uk> wrote:
2 > On Mon, 20 Jan 2014 06:38:40 -0500, Tanstaafl wrote:
3 >
4 >> The pertinent part of the script is:
5 >>
6 >>> # delete aged backup files, keeping 60 nightlies and 45 (5 days of)
7 >>> hourlies rm $(ls -1t $MySQL_BACKUP_DIR_nightly/* | tail -n +61)
8 >>> rm $(ls -1t $MySQL_BACKUP_DIR_hourly/* | tail -n +46)
9 >>
10 >> It works fine and does what it is supposed to, but the email I get as a
11 >> result of the script running says only this in the body:
12 >>
13 >> rm: missing operand
14 >> Try 'rm --help' for more information.
15 >
16 > Do you have a file with an odd name in either of those directories,
17 > particularly one starting with a -
18
19 No, they are all sql.gz files, starting with the date, like:
20
21 2014-01-05_0958-hostname-all.sql.gz
22
23 > You could try adding "echo rm $(ls -1t ..." to the script to see what it
24 > is actually trying to run.
25 >
26 > Or you could use find instead
27 >
28 > find $MySQL_BACKUP_DIR_nightly -type f -mtime +60 -exec rm {} +
29
30 Ok, may try that... thx...

Replies