How to count the total number of the opened files by the users and processes on my machine

410

Use wc, the option -l counts the lines:

lsof -Fn -u teeba| sort  | uniq | grep /home | wc -l

This will output 25 in your case.

Additionally you can number the lines with nl:

lsof -Fn -u teeba| sort  | uniq | grep /home | nl
Share:
410

Related videos on Youtube

Alex
Author by

Alex

Updated on September 18, 2022

Comments

  • Alex
    Alex over 1 year

    I have a osgi component which works with JCR (for example, CRUD).

    @Component
    @Service
    public class SomeServiceImpl implements SomeService {
    
        @Reference
        private ResourceResolverFactory resourceResolverFactory;
    
        private ResourceResolver resourceResolver;
    
        @Activate
        private void init() {
           resourceResolver = resourceResolverFactory.getServiceResourceResolver(
                  Collections.singletonMap(ResourceResolverFactory.SUBSERVICE, "myService"));
        }
    
        @Override
        public void serve() {
            //does something with resourceResolver
        }
    
        @Deactivate
        private void dispose() {
            resourceResolver.close();
        }
    }
    

    It creates new instance of resourceResolver and keeps it as long as this service is alive. From time to time this service is invoked outside.

    My questions are:

    1. Is it correct approach where I once create resourceResolver and reuse it? Is it constantly?
    2. Do I have guarantees that underlying session will not be expired?
    3. By the way How long resourceResolver and their session lives and where can I see it?
    4. What about concurrency? Imagine this service is invoked from serveral places parallely, Does Jackrabbit guarantee me consistency?

    @Component
    @Service
    public class SomeServiceImpl implements SomeService {
    
        @Reference
        private SlingRepository slingRepository;
    
        private Session session;
    
        @Activate
        private void init() {
           session = slingRepository.login();
        }
    
        @Override
        public void serve() {
            //does something with session
        }
    
        @Deactivate
        private void dispose() {
            session.logout();
        }
    }
    

    The same questions for another service (with session implementation).

    It will be nice to see some proofs if it's possible. Maybe docs...

    Thanks.

  • Alex
    Alex over 7 years
    by the way where I can find some inforamtion about "AEM is collecting unclosed sessions after some time."? In this article it talks that it closes an underlying JCR Session of the ResourceResolver when the ResourceResolver object is Garbage Collected. Do you mean that AEM has real job which with some period closees unclosed sessions or mentioned in the article behavior?
  • Robert Munteanu
    Robert Munteanu about 7 years
    Do you have any references for "AEM is collecting unclosed sessions after some time." ? I am not aware of any such functionality in the product.