Tar files older than x days

solaris

I have a directory which I would like to scan through and add each file older than 50 days to a new archive named archive.tar

All files older than 50 days must be in one big tar not a tar for each file.

How can I do this?

Best Answer

This will do the trick:

# find /path/to/files -type f -mtime +50 | xargs tar cvf archive.tar

You can stick it in crontab and have it run daily.

Edit: Remember that this will not remove the files from the system, only add them to the archive.