Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: "Peter H. Coffin" Newsgroups: comp.lang.php Subject: Re: Files getting clobbered when I run out of disk space Date: Mon, 7 Jan 2013 21:47:13 -0600 Organization: A noiseless patient Spider Lines: 31 Message-ID: References: <89d3884a-015f-42a7-910f-7c1c77ba68d9@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: mx04.eternal-september.org; posting-host="95eff61b8f8136989e561408eae2762f"; logging-data="27550"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+XtNse5TYklINLOUJoJDjM" User-Agent: slrn/0.9.9p1 (OpenBSD) Cancel-Lock: sha1:+CHvSgNqhVq1hoxmZFrPGCvDbTM= Xref: csiph.com comp.lang.php:8042 On Mon, 7 Jan 2013 15:49:30 -0800 (PST), faraz@squashclub.org wrote: > There was some disk space issues with my server. As a result any script > I had that opened a file for writing would clobber it i.e truncate it to > zero length . Since there was no space left on device, nothing would be > written to it. > > Are there any workarounds to this? Here is some code I came up, but it is untested as I currently have disk space on my account: > > ///////////////////////////// > > function check_disk_space() { > > global $home_dir; > > $fp = fopen( "$home_dir/cgi-bin/scripts/check_disk_space" , "w" ); > > fwrite ($fp, 'hello world' ) || die_sub ( 'Error checking for disk space' ); > > fclose ($fp) || die_sub ( 'Error checking for disk space' ); > > // unlink ( 'check_disk_space' ); > > } // end function Freeing up some space on the device is out of the question? -- "If Ace [Double] Books ever came out with an edition of The Bible, both books would be edited down to 40,000 words, and they'd be renamed "Master of Chaos" and "The Thing With Three Souls." -- Terry Carr