Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hopefully someone knows whats wrong with this script. I have a game server that basically deletes any player files that haven't been modified in atleast 90 days.
Code:
#!/bin/sh
# Running this script will remove all player files older than 90 days.
echo ;date
echo "Cleaning up 90 day old player files....."
find -type f -mtime +90
# Actual deletion:
find -type f -mtime +90 -name "*.bic" -exec rm -f {} \;
echo "Cleaning is done."
It works except people with funny names don't work.
For an example:
Code:
./Art?_?miS/?_?artemide?_?.bic
Just wanted to see if there is a way for the above script to catch these wierd characters.
Can you at least "find -inum $inode -exec rm {} \;" manually, where "$inode" is one of the inode numbers from running "find -type f -mtime +90 -name "*.bic" -printf "%i\n"? What is your locale? Does "find -type f -mtime +90 -name "*.bic" -print0 | xargs -0 -iX /bin/ls --quoting-style=c --show-control-chars -1iQ 'X'" show different output from what you posted above?
Can you at least "find -inum $inode -exec rm {} \;" manually, where "$inode" is one of the inode numbers from running "find -type f -mtime +90 -name "*.bic" -printf "%i\n"? What is your locale? Does "find -type f -mtime +90 -name "*.bic" -print0 | xargs -0 -iX /bin/ls --quoting-style=c --show-control-chars -1iQ 'X'" show different output from what you posted above?
I tried your above command but it didn't them either. I did find out something though.
The -name "*.bic" isn't finding them.
Code:
[root@mars servervault]# find -type f -mtime +90
./Art?_?miS/?_?artemide?_?.bic
./The DC DC/??z?58555g.bic
./The DC DC/?c?7?z15r554.bic
./The DC DC/?z???hn8.bic
./The DC DC/c??0a.bic
./Alastorgame/?r?__kll.bic
./Alastorgame/?r?kll6.bic
./Alastorgame/?r?kll5.bic
./Alastorgame/?rnkillh?h.bic
./Alastorgame/?r?kll.bic
[root@mars servervault]# find -type f -mtime +90 -name "*.bic"
[root@mars servervault]#
So I wonder why * isn't treated as a wild card like it should be.
It should be sane since in your search for that mtime only bic
with funny characters showed up...
Cheers,
Tink
That does work. I was just hoping to keep it to bic files only because sometimes I keep backup player files there. It seems I might have to resort to that though unless I can get this to work.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.