Agnus Dei (jackal) wrote,
Agnus Dei
jackal

How to find hard links linked to a file.

I can't gzip my logs because I've got hidden hard links... here's how to find them.


[root@pod01-ema-01 httpd]# find /var/log/httpd/ -name "*.txt" -type f -mtime +7 -exec gzip {} \;
gzip: /var/log/httpd/ema.md-access_log.2013-03-10.txt has 1 other link  -- unchanged
gzip: /var/log/httpd/ema.md-access_log.2013-03-03.txt has 1 other link  -- unchanged
gzip: /var/log/httpd/ema.md-ssl-access_log.2013-03-03.txt has 1 other link  -- unchanged
gzip: /var/log/httpd/ema.md-error_log.2013-03-09.txt has 1 other link  -- unchanged
gzip: /var/log/httpd/ema.md-ssl-error_log.2013-03-03.txt has 1 other link  -- unchanged
gzip: /var/log/httpd/ema.md-error_log.2013-03-03.txt has 1 other link  -- unchanged
gzip: /var/log/httpd/ema.md-ssl-access_log.2013-03-10.txt has 1 other link  -- unchanged
gzip: /var/log/httpd/ema.md-ssl-error_log.2013-03-10.txt has 1 other link  -- unchanged
gzip: /var/log/httpd/ema.md-error_log.2013-03-16.txt has 1 other link  -- unchanged


[root@pod01-ema-01 httpd]# stat /var/log/httpd/ema.md-access_log.2013-03-10.txt
  File: `/var/log/httpd/ema.md-access_log.2013-03-10.txt'
  Size: 70688           Blocks: 152        IO Block: 4096   regular file
Device: ca41h/51777d    Inode: 21393       Links: 2
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-03-25 20:03:28.707043413 +0000
Modify: 2013-03-10 23:59:13.394046125 +0000
Change: 2013-03-11 00:03:40.273046121 +0000


[root@pod01-ema-01 httpd]# ls -i /var/log/httpd/ema.md-access_log.2013-03-10.txt | awk '{print $1}' | xargs find . -inum 
./ema.md-access_log-20130310
./ema.md-access_log.2013-03-10.txt

Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 0 comments