LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-27-2016, 06:56 AM   #1
sub320
Member
 
Registered: Jan 2016
Posts: 40

Rep: Reputation: Disabled
process to use open files


I would like to test open files usage in my system, if I want to create a process ( or script ) that can use a certain amount ( eg. 1000 ) of open files , is it possible to create such process ( or script ) ?

thanks
 
Old 01-27-2016, 07:04 AM   #2
Habitual
LQ Addict
 
Registered: Jan 2011
Posts: 8,446
Blog Entries: 11

Rep: Reputation: 2369Reputation: 2369Reputation: 2369Reputation: 2369Reputation: 2369Reputation: 2369Reputation: 2369Reputation: 2369Reputation: 2369Reputation: 2369Reputation: 2369
check out lsof?
 
Old 01-27-2016, 08:02 AM   #3
sub320
Member
 
Registered: Jan 2016
Posts: 40

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Habitual View Post
check out lsof?
yes , lsof may count the number of open files , if I want to run a process that will use a certain amount of open files , is it possible ? thanks
 
Old 01-27-2016, 08:32 AM   #4
Habitual
LQ Addict
 
Registered: Jan 2011
Posts: 8,446
Blog Entries: 11

Rep: Reputation: 2369Reputation: 2369Reputation: 2369Reputation: 2369Reputation: 2369Reputation: 2369Reputation: 2369Reputation: 2369Reputation: 2369Reputation: 2369Reputation: 2369
I dunno. Sorry.
 
Old 01-27-2016, 08:38 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,430

Rep: Reputation: 2768Reputation: 2768Reputation: 2768Reputation: 2768Reputation: 2768Reputation: 2768Reputation: 2768Reputation: 2768Reputation: 2768Reputation: 2768Reputation: 2768
I do not really understand your problem, what is the goal. Actually you can run open(filename) with random names or counters in a loop if you want.
 
Old 01-27-2016, 07:34 PM   #6
sub320
Member
 
Registered: Jan 2016
Posts: 40

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
I do not really understand your problem, what is the goal. Actually you can run open(filename) with random names or counters in a loop if you want.
thanks reply ,

what I want to have a process that use open files up to a certain amount .

in my case , I have set the ulimit -u to 2048 in my system , I would like to have a process that will use the open files up to a certain amount eg. 1000 , that I can test my application when the current open files is at the amount of 1000 .

may I know if use a script which have a loop to open file continously , is it work ?

or simply

if I would like to have a script run in a loop that repeatly use open files resource , what can I do ?

thanks

thanks

Last edited by sub320; 01-27-2016 at 07:53 PM.
 
Old 01-27-2016, 09:02 PM   #7
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,289

Rep: Reputation: 211Reputation: 211Reputation: 211
Post

Quote:
Originally Posted by sub320 View Post
thanks reply ,

what I want to have a process that use open files up to a certain amount .

in my case , I have set the ulimit -u to 2048 in my system , I would like to have a process that will use the open files up to a certain amount eg. 1000 , that I can test my application when the current open files is at the amount of 1000 .

may I know if use a script which have a loop to open file continously , is it work ?

or simply

if I would like to have a script run in a loop that repeatly use open files resource , what can I do ?

thanks

thanks
A script the uses open files resource? What do you mean by that?

Do you mean something like this?=> http://serverfault.com/questions/640...rce-limit-1024
 
Old 01-27-2016, 09:19 PM   #8
sub320
Member
 
Registered: Jan 2016
Posts: 40

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by JJJCR View Post
A script the uses open files resource? What do you mean by that?

Do you mean something like this?=> http://serverfault.com/questions/640...rce-limit-1024
thanks reply ,

the usage of open files could be check by "lsof |wc " , when run application , it should use open files , what I would like is to have a process ( or script ) that eating up an additional file descriptor , so that the open files usage increases to a certain amount .

thanks
 
Old 01-27-2016, 09:25 PM   #9
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,702

Rep: Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270
What do you really want to do?

There are disk benchmark utilities (bonnie for instance) that will create/read/write/delete files - many thousands of them...

The usual limit for a single process is 1024 open files. This is at least partly due to the limit on the "select" function that is frequently used to signal file descriptors ready for I/O. For more than 1000, you have to use the poll/epoll function instead and get a bigger ulimit quota limit.
 
Old 01-27-2016, 10:07 PM   #10
sub320
Member
 
Registered: Jan 2016
Posts: 40

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jpollard View Post
What do you really want to do?

There are disk benchmark utilities (bonnie for instance) that will create/read/write/delete files - many thousands of them...

The usual limit for a single process is 1024 open files. This is at least partly due to the limit on the "select" function that is frequently used to signal file descriptors ready for I/O. For more than 1000, you have to use the poll/epoll function instead and get a bigger ulimit quota limit.
thanks reply ,

may be we are talking different thing , I just would like have a script to repeatly eating up open files , so that make it increase to a certain level .

thanks
 
Old 01-28-2016, 01:18 AM   #11
sub320
Member
 
Registered: Jan 2016
Posts: 40

Original Poster
Rep: Reputation: Disabled
may be there is a simpler method .

if I would like to have a script a open a certain amount of files ( eg. 1000 ) in background mode , would advise how to write such script ?

thanks
 
Old 01-28-2016, 01:29 AM   #12
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,354
Blog Entries: 55

Rep: Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541
IIRC the 'stress' application may help.
 
Old 01-28-2016, 07:33 AM   #13
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 5,407
Blog Entries: 12

Rep: Reputation: 1882Reputation: 1882Reputation: 1882Reputation: 1882Reputation: 1882Reputation: 1882Reputation: 1882Reputation: 1882Reputation: 1882Reputation: 1882Reputation: 1882
You can write a program or a script to open a file.

You can then make a loop within your script or program to open numerous files.

As far as writing scripts, a suggestion is BASH, also consider BASH Advanced Reference.

Your best shot at getting better recommendations from LQ members is to start by writing your own script, posting what you've done and indicating where you are stuck. Members likely will then offer suggestions how to fix or improve your script. But people will not just write a script for you.

Another thing to consider is also to inform persons exactly what your ultimate goal is, not just the immediate desire to open a bunch of files. Many persons here can do that using their own custom made script or program. Some certainly have done this in the past, but they've done this to test something, or verify something. What others are pointing out are that there are means to verify performance or capabilities of a system without re-inventing work. But if this is for your own personal study, then that's also great too. In fact, people will likely explain in more detail to provide for your benefit.

Therefore you either need to share a bit more about your intentions, or do some work on your own and not ask for simple handouts.

Last edited by rtmistler; 01-28-2016 at 07:35 AM.
 
Old 01-28-2016, 12:18 PM   #14
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,620

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
Quote:
Originally Posted by sub320 View Post
thanks reply ,

what I want to have a process that use open files up to a certain amount
in my case , I have set the ulimit -u to 2048 in my system , I would like to have a process that will use the open files up to a certain amount eg. 1000 , that I can test my application when the current open files is at the amount of 1000 .

may I know if use a script which have a loop to open file continously , is it work ?
thanks
Loops for, while and until

just pick the best suited loop for your use

Code:
#!/bin/bash
  
MAXFILES=1000


code to open  up many files goes here , then you can check it with this


HowManyOpen="$(lsof | wc -l)"

if [[ "$HowManyOpen" >= "$MAXFILES" ]] ; then

do something about it ...

fi
or you ucould write it to open up a fixed amount of files and be set with that.

The Mother of invention bears the child of necessity

Last edited by BW-userx; 01-28-2016 at 12:44 PM.
 
Old 01-29-2016, 04:59 AM   #15
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 30
Quote:
Originally Posted by BW-userx View Post
Loops for, while and until

just pick the best suited loop for your use

Code:
#!/bin/bash
  
MAXFILES=1000


code to open  up many files goes here , then you can check it with this


HowManyOpen="$(lsof | wc -l)"

if [[ "$HowManyOpen" >= "$MAXFILES" ]] ; then

do something about it ...

fi
or you ucould write it to open up a fixed amount of files and be set with that.

The Mother of invention bears the child of necessity
Thanks reply ,

"do something about it ..." <<== Could you suggest what should do in this part ?

Thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: The value of open source is the open development process LXer Syndicated Linux News 0 07-21-2014 11:40 AM
[SOLVED] finding per process open files Chickentree Programming 2 02-03-2014 10:28 AM
Setting open files for a process submerge Linux - Newbie 4 06-03-2013 12:29 PM
nagios plugin for monitoring the no. of open files for a particular process sarathveera Linux - Software 1 02-05-2010 12:43 AM
LXer: Linux Process Management: Using lsof to List Open Files LXer Syndicated Linux News 0 04-10-2009 07:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration