0

I want to calculate the temporary amount of disk space used by an application in GB on Linux(ubuntu 14.04) How can I do it?

closed as unclear what you're asking by user34720, Rui F Ribeiro, Kusalananda, Jeff Schaller, Archemar Jun 14 '17 at 19:15

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

2

I want to calculate the temporary amount of disk space used by an application in GB

In general you cannot do that. However, you might use du(1), df(1) (perhaps using system(3) or popen(3) from inside your application).

BTW, you don't define what is the temporary amount of disk space. Is it related to tmpfile(3) or mkstemp(3)? Or open(2) with O_TMPFILE?

(actually, defining precisely what is the temporary amount of disk space is not easy at all; once you did that you could get a better answer)

Maybe you want to measure the size of temporary files in some process running your application (that is, those files which have an open file descriptor, but whose name was unlink-ed from their directory). Then read much more about proc(5). From inside your application, consider using /proc/self/fd/ (you could opendir(3), readdir(3), closedir it etc). From outside your application, if its process is 1234, consider using /proc/1234/fd/

-1

If you're trying to grab how much space was consumed on installation, a combination of yum whatprovides and yum info should set you right.

yum whatprovides sed
sed-4.2.2-5.el7.x86_64 : A GNU stream text editor
Repo        : rhel-7-server-rpms

yum info sed-4.2.2-5.el7.x86_64 ##CHECK Size:
Installed Packages
Name        : sed
Arch        : x86_64
Version     : 4.2.2
Release     : 5.el7
Size        : 587 k
Repo        : installed
From repo   : anaconda
Summary     : A GNU stream text editor
URL         : http://sed.sourceforge.net/
License     : GPLv3+
Description : The sed (Stream EDitor) editor is a stream or batch (non-interactive)
            : editor.  Sed takes text as input, performs an operation or set of
            : operations on the text and outputs the modified text.  The operations
            : that sed performs (substitutions, deletions, insertions, etc.) can be
            : specified in a script file or from the command line.
  • I want to benchmark tools in terms of their maximum(peak) disk use.The tool create temporary files on disk when it needs more memory(when the amount of available system RAM is insufficient). I want to figure out how much peak disk space it utilizes (bytes written) for storing temporary files during its execution. Can I have shell script which executes like, input : ./peak_disk.sh ./tool_command output : peak disk utilised = .. GB – Swati Jun 19 '17 at 12:13
  • Best I can offer would be using strace and throwing the output to a file, then running your install.strace -fo /tmp/install.log -f -e trace=file install.sh. (-f should follow child processes). This will allow a full audit of all files/directories touched. Otherwise, there are utilities like installwatch, but I have no idea if that is maintained anymore. – Kristopher Kahn Jun 19 '17 at 12:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.