command usage on find with xargs and tar

my task : tar up large bunch of files(about 10,000 files) in the current directories that created more than 30 days ago
but it come with following error

find ./ -ctime +30 | xargs tar rvf test1.tar
tar: test1.tar: A file or directory in the path name does not exist.

If the tar file does not exist you cannot update it!

So I would create the tar file first adding a single readme file describing what it contains, then do what you were going to do.

However, for sanities sake, use find to create the list of files, then you will have a record of what you were putting in the tar file, so if you need to move or delete them you can do so from that list.

Also, you don't want the tar file itself to be included.

thank for your reply, it work with your recommandation but it is kind of weird way to make it work in my mind. :slight_smile:

When you use find already, what do you need xargs for? Just a suggestion: use the -exec clause in find:

find . -ctime +30 -exec tar -rvf test1.tar {} \;

bakunin