Backup script, to date-stamp file & delete backup files Older than 7 days
am trying this script :- ................................ #!/bin/sh # backup /var # cd ~ exec tar czvf /bup/var`date +%y%m%d`.tar.gz /var/named /var/cron/tabs /var/spool/mail /usr/X11R6/lib/X11/app-defaults /usr/X11R6/lib/X11/fonts/greek {} \; >/dev/null 2>&1 # delete /bup files older than 7 days cd /bup find ./test -mtime +7 -exec rm -f {} \* ; cd ~ ............................... . . . But, the "find & Delete" line is not working :( < find ./test -mtime +7 -exec rm -f {} \* ; > does not run, and, complains : " Find missing argument to `-exec' " What do I need, please, to make it find and delete backup files older than 7 Days ? thanks ____________ sent on Linux ____________
-----Original Message-----
From: pinto
am trying this script :- ................................ #!/bin/sh # backup /var # cd ~ exec tar czvf /bup/var`date +%y%m%d`.tar.gz /var/named /var/cron/tabs /var/spool/mail /usr/X11R6/lib/X11/app-defaults /usr/X11R6/lib/X11/fonts/greek {} \; >/dev/null 2>&1 # delete /bup files older than 7 days cd /bup find ./test -mtime +7 -exec rm -f {} \* ;<--remove, not needed cd ...............................
. . . But, the "find & Delete" line is not working :(
< find ./test -mtime +7 -exec rm -f {} \* ; > does not run, and, complains :
" Find missing argument to `-exec' "
What do I need, please, to make it find and delete backup files older than 7 Days ?
thanks
____________
sent on Linux
____________
Try removing the trailing ; from the find line. Ken
On Saturday 22 May 2004 12:54, Ken Schneider wrote:
-----Original Message----- From: pinto
To: SuSE List Date: Sat, 22 May 2004 17:20:13 +0000 Subject: [SLE] Backup script, to date-stamp file & delete backup files Older than 7 days am trying this script :- ................................ #!/bin/sh # backup /var # cd ~ exec tar czvf /bup/var`date +%y%m%d`.tar.gz /var/named /var/cron/tabs /var/spool/mail /usr/X11R6/lib/X11/app-defaults /usr/X11R6/lib/X11/fonts/greek {} \; >/dev/null 2>&1 # delete /bup files older than 7 days cd /bup find ./test -mtime +7 -exec rm -f {} \* ;<--remove, not needed cd ...
" Find missing argument to `-exec' "
...
____________
Try removing the trailing ; from the find line.
Perhaps find has a feature I don't understand, but as far as I know the semicolon is required. The problem I see is that the semicolon needs to be protected from the shell. Something like this: find ./test -mtime +7 -exec rm -f {} \ ; I can't speak to the correctness of the rest of the command but am highly suspicious of the "\*" in the original version given above. -- Robert C. Paulsen, Jr. robert@paulsenonline.net
On Saturday 22 May 2004 18:09, Robert Paulsen wrote:
Something like this:
find ./test -mtime +7 -exec rm -f {} \ ;
Dear Mr Paulsen ~ Many thanks, in case relevant, my SuSE is version 8.0 . . . i have tried : find ./test -mtime +7 -exec rm -f {} \ ; But, am greeted by complaint "find: missing argument to '-exec' " . . . what, please, do you think is needed? thanks ____________ sent on Linux ____________
On Saturday 22 May 2004 14:04, pinto wrote:
On Saturday 22 May 2004 18:09, Robert Paulsen wrote:
Something like this:
find ./test -mtime +7 -exec rm -f {} \ ;
___________________
Dear Mr Paulsen ~ Many thanks,
in case relevant, my SuSE is version 8.0
. . . i have tried :
find ./test -mtime +7 -exec rm -f {} \ ;
But, am greeted by complaint "find: missing argument to '-exec' "
. . . what, please, do you think is needed?
Your line above has a space between the backslash and the semicolon. The backslash protects whatever character immediately follows it, which is a space in your line above. You need to protect the semicolon from the shell so you need "\;" with no spaces between. -- Robert C. Paulsen, Jr. robert@paulsenonline.net
On Saturday 22 May 2004 21:37, Robert Paulsen wrote:
The backslash protects whatever character immediately follows it, which is a space in your line above. You need to protect the semicolon from the shell so you need "\;" with no spaces between.
Thank you. -- best wishes ____________ sent on Linux ____________
On Saturday 22 May 2004 17:54, Ken Schneider wrote:
# delete /bup files older than 7 days cd /bup find ./test -mtime +7 -exec rm -f {} \* ;<--remove, not needed
many thanks . . . i tried removing ";" ~ the result was, from the root # prompt, the prompt became ">" { i wonder what the change from # to > means ?} . . . but, the script will not run, yet? best wishes ____________ sent on Linux ____________
On Saturday 22 May 2004 14:03, pinto wrote:
On Saturday 22 May 2004 17:54, Ken Schneider wrote:
# delete /bup files older than 7 days cd /bup find ./test -mtime +7 -exec rm -f {} \* ;<--remove, not needed
______________
many thanks . . . i tried removing ";"
Don't do that :-)
~ the result was, from the root # prompt, the prompt became ">"
{ i wonder what the change from # to > means ?}
That is a "secondary prompt" it means the shell is waiting for you to finish typing a command. If you put a backslash as the last character on a line it "protects" the enter key from the shell so the shell thinks there is still more to come for the command you have typed (as if you hadn't hit enter yet). It (the backslash) is effectively a continuation character when it is the last character on a line. -- Robert C. Paulsen, Jr. robert@paulsenonline.net
On Saturday 22 May 2004 21:42, Robert Paulsen wrote:
If you put a backslash as the last character on a line it "protects" the enter key from the shell so the shell thinks there is still more to come for the command you have typed (as if you hadn't hit enter yet). It (the backslash) is effectively a continuation character when it is the last character on a line.
thank you, kindly . . . most helpful. -- best wishes ____________ sent on Linux ____________
-----Original Message-----
From: pinto
On Saturday 22 May 2004 17:54, Ken Schneider wrote:
# delete /bup files older than 7 days cd /bup find ./test -mtime +7 -exec rm -f {} \* ;<--remove, not needed
Must wake up before answering. You need to remove the * not the ; Ken
On Saturday 22 May 2004 22:14, Ken Schneider wrote:
need to remove the * not the ;
~ many thanks. Thus :- find ./test -mtime +7 -exec rm -f {} \ ; -- best wishes ____________ sent on Linux ____________
participants (3)
-
Ken Schneider
-
pinto
-
Robert Paulsen