Limiting output file size


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Limiting output file size
# 1  
Old 04-12-2010
Limiting output file size

Hi guys,
I want to know if there is a way to check the current size of the file that I output "stuff" to. For example, if I run a command that outputs data (like another shell script or C program) and i do something like
`./a.out &> tempfile.txt` within the script,
I want to be constantly updated about the size of tempfile.txt. I was wondering if there were any shell tools that would allow me to do such a thing, also, if there was a kill command for the ./a.out program that would stop execution after a certain output file size.
# 2  
Old 04-12-2010
check out the setrlimit() system call. http://linux.die.net/man/2/setrlimit for linux. Based on your username, solaris also supports setrlimit()

Use the RLIMIT_FSIZE parameter.

Last edited by jim mcnamara; 04-12-2010 at 10:58 PM.. Reason: bad url
# 3  
Old 04-12-2010
Try using the dd utility. You can set a maximum size, and you can send an INFO signal to it to get the file size. From the man page...
Code:
   Sending an `INFO' signal to a running `dd' process makes it print
I/O statistics to standard error and then resume copying.  In the
example below, `dd' is run in the background to copy 10 million blocks.
The `kill' command makes it output intermediate I/O statistics, and
when `dd' completes, it outputs the final statistics.

     $ dd if=/dev/zero of=/dev/null count=10MB & pid=$!
     $ kill -s INFO $pid; wait $pid
     3385223+0 records in
     3385223+0 records out
     1733234176 bytes (1.7 GB) copied, 6.42173 seconds, 270 MB/s
     10000000+0 records in
     10000000+0 records out
     5120000000 bytes (5.1 GB) copied, 18.913 seconds, 271 MB/s

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Limiting Bash array single line output

#!/bin/bash PH=(AD QD QC 5H 6C 8C 7D JH 3H 3S) echo ${PH} In the above array, how can I print to screen just the first 8 elements of ${PH} and have the last 2 elements print just below the first line starting underneath AD? I need to do this in order to save terminal window spacing... (5 Replies)
Discussion started by: cogiz
5 Replies

2. UNIX for Advanced & Expert Users

Limiting size of rsync batch output

Anyone know if there's a way to limit the size of rsync batch output blob? I need each batch to fix on a 64GB USB key. Using syntax like: rsync -av --only-write-batch=/Volumes/usb/batch --stats /Users/dfbadmin/sandbox/ /Users/dfbadmin/archives/ (7 Replies)
Discussion started by: dfbills
7 Replies

3. Shell Programming and Scripting

Output after a perl script gives a file with size zero.

Hi, I have a unix shell script which generates a flat file after connecting to Teradata servers to fetch tables and views and also picks up modified unix scripts from the specified paths. Later on the script calls a perl script to assign a value based on the type of object in the flat file which... (2 Replies)
Discussion started by: yohasini
2 Replies

4. UNIX for Dummies Questions & Answers

Limiting User mailbox size in /var/spool

How can one limit the size of user mailboxes in /var/spool/mail? (0 Replies)
Discussion started by: proactiveaditya
0 Replies

5. UNIX for Advanced & Expert Users

Summing file size and output

:rolleyes:Hi, I need to find the sum of size of specific files in my directory Say for ex, mydir$ ls -ltr permisssion links user group size date time filename I want to display the sum of size of filenames having pattern "TS55". Note file size in this directory is near 400 MB. mydir$... (1 Reply)
Discussion started by: ramkrix
1 Replies

6. UNIX for Dummies Questions & Answers

ls -l output file size

Hi Guys, I'm working on various platforms: Solaris 8 HP Tru64 RH Linux I'm on the HP Tru64 system and I've got to audit a particular directory for large files that are no longer being used. If I do an ls -l I get to see the file size. I'd just like to be clear on what that file size... (4 Replies)
Discussion started by: Stin
4 Replies

7. UNIX for Dummies Questions & Answers

limiting home directory size for a group

Is there a way to set the size of the home directory for every single user in a specific group, in more details: I have a group & i will have to add about 20 users to it to be their home directories. i want each of the home directories for this group to be limited to 50 MB Help? (11 Replies)
Discussion started by: Katkota
11 Replies

8. Shell Programming and Scripting

compare file size from a output file from a script

Hi guys, firstly I'm working on SunOS 5.10 Generic_125100-10 sun4u sparc SUNW,Sun-Fire-V240 I've made a script to compress two directory and then send them to an other server via ftp. This is working very well. Inside theis script I decide to log usefull data for troubleshooting in case of... (7 Replies)
Discussion started by: moustik
7 Replies

9. UNIX for Dummies Questions & Answers

limiting the size of syslog log files

I would like to limit the size of syslog log files. Is there a setting I can enter in syslog.conf that does this for me. Ideally I would like something along the lines of a circular buffer of N bytes. P.S. I'm a new user, and this site is awesome. I wish I found it earlier. Thanks, David (1 Reply)
Discussion started by: dmirza
1 Replies

10. UNIX for Dummies Questions & Answers

tar file size (volume) limiting

Hi I am trying to create tar files of a whole bunch of files and want to limit them to 50Mb each. I have tried using the -k option but cannot get it to work. Has anyone out there had success creating these? Cheers Ian (1 Reply)
Discussion started by: bigjeff
1 Replies
Login or Register to Ask a Question