- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Abandoned files
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-29-2009 01:33 AM
тАО01-29-2009 01:33 AM
We have a script to check for abandoned files on our HP-UX server. Attaching the script for reference.
Now, we are asked to assign the user and group as "root" for these files. We have abandoned files aroung 3000+ on some servers. Can someone provide a script to do this rather than doing it one file at a time.
Any input is really appreciated.
Thank You..
Regards,
Ashish A. Lahori
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-29-2009 01:40 AM
тАО01-29-2009 01:40 AM
Re: Abandoned files
for file in $(cat /var/tmp/abandoned_files.txt)
do
echo "Changing Permission of file $file to root.\n"
chown root:root $file
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-29-2009 01:42 AM
тАО01-29-2009 01:42 AM
Re: Abandoned files
find / -local \( -nouser -o -nogroup \) -exec chown root:root {} \; 2>/dev/null |grep -v "total 0"
Sagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-29-2009 01:44 AM
тАО01-29-2009 01:44 AM
SolutionYou need to change your find so you don't invoke ls. Or you need to add -d so ll on directories don't list the files under them:
awk '{print $9}' /var/tmp/abandoned_files.txt | xargs chown bin:bin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-29-2009 01:50 AM
тАО01-29-2009 01:50 AM
Re: Abandoned files
If lots of files, "for" may not work. No need for evil cat.
>Sagar: find / -local \( -nouser -o -nogroup \) -exec chown root:root {} \; 2>/dev/null |grep -v "total 0"
No need for that grep (ll output) and that stderr redirection. Also replace that \; with "+" for performance.
- Tags:
- evil cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-29-2009 01:54 AM
тАО01-29-2009 01:54 AM
Re: Abandoned files
the for loop should be
for file in $(awk '{print $9}'/var/tmp/abandoned_files.txt)
or the other find commands suggested will work as well - although these will have to search the filesystem again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-29-2009 01:55 AM
тАО01-29-2009 01:55 AM
Re: Abandoned files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-29-2009 02:16 AM
тАО01-29-2009 02:16 AM
Re: Abandoned files
No need for a for-loop because you can put these files on chmod directly:
chmod bin:bin
$(awk '{print $9}' /var/tmp/abandoned_files.txt)
>do you know what the limit on a for loop is?
I thought it is at least 1 Mb.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-29-2009 03:35 AM
тАО01-29-2009 03:35 AM
Re: Abandoned files
I have made a seperate script to assign the abandoned file ownership to bin:bin. However, I get the below error:
---------------------------------
# ./aban_chk.sh
Usage: chmod [-A] [-R] [ugoa]+-=[rwxXstugo][,...] file ...
./aban_chk.sh[2]: .cshrc: not found.
---------------------------------
Attaching the script in the .txt file.
Kindly assist.
Thanks..
Regards,
Ashish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-29-2009 04:05 AM
тАО01-29-2009 04:05 AM
Re: Abandoned files
One more question, few of the abandoned files seen in file abandoned_files.txt is attached.
My question is, how do i know the absolute path of a file say i.e SDBM_File.pm .
Kindly assist.
Thanks.
Regards,
Ashish