Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting files

Status
Not open for further replies.

Chrissirhc

Programmer
May 20, 2000
926
GB
#
# Clean out old log files.
#
30 18 * * 0-6 ( /usr/bin/find /tmp -name '*log*' -user me -mtime +7 -print | xargs rm ) > /dev/null 2>&1
#

Is that a good approach? I found it in a crontab.
 
-user me
Really ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi,
Before deleting your log files, it's better to have some information about what is deleted and then delete what is to be deleted.

# log the candidate file for deleting
30 18 * * 0-6 ( /usr/bin/find /tmp -name '*log*' -user me -mtime +7 -print -ls ) > /tmp/deleted_file.$(date +%Y%m%d )
# delete candidate files
30 18 * * 0-6 ( /usr/bin/find /tmp -name '*log*' -user me -mtime +7 -print | xargs rm ) > /dev/null 2>&1

and as PHV focuses, be sur(e) that the user you want logs to be deleted is 'me'

Ali
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top