Gentoo Archives: gentoo-user

From: Neil Bothwick <neil@××××××××××.uk>
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 11:51:58
Message-Id: 20140120115134.00bcf22f@digimed.co.uk
In Reply to: [gentoo-user] "rm: missing operand" in emailed result of cron job that uses rm to remove aged files by Tanstaafl
1 On Mon, 20 Jan 2014 06:38:40 -0500, Tanstaafl wrote:
2
3 > The pertinent part of the script is:
4 >
5 > > # delete aged backup files, keeping 60 nightlies and 45 (5 days of)
6 > > hourlies rm $(ls -1t $MySQL_BACKUP_DIR_nightly/* | tail -n +61)
7 > > rm $(ls -1t $MySQL_BACKUP_DIR_hourly/* | tail -n +46)
8 >
9 > It works fine and does what it is supposed to, but the email I get as a
10 > result of the script running says only this in the body:
11 >
12 > rm: missing operand
13 > Try 'rm --help' for more information.
14
15 Do you have a file with an odd name in either of those directories,
16 particularly one starting with a -
17
18 You could try adding "echo rm $(ls -1t ..." to the script to see what it
19 is actually trying to run.
20
21 Or you could use find instead
22
23 find $MySQL_BACKUP_DIR_nightly -type f -mtime +60 -exec rm {} +
24
25
26 --
27 Neil Bothwick
28
29 The trouble with life is that you are halfway through it before you
30 realize it's a "do it yourself" thing.

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies