Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #8040 > unrolled thread
| Started by | faraz@squashclub.org |
|---|---|
| First post | 2013-01-07 15:49 -0800 |
| Last post | 2013-01-08 23:20 +0100 |
| Articles | 7 — 7 participants |
Back to article view | Back to comp.lang.php
Files getting clobbered when I run out of disk space faraz@squashclub.org - 2013-01-07 15:49 -0800
Re: Files getting clobbered when I run out of disk space Adam Harvey <usenet@adamharvey.name> - 2013-01-08 01:07 +0000
Re: Files getting clobbered when I run out of disk space "Peter H. Coffin" <hellsop@ninehells.com> - 2013-01-07 21:47 -0600
Re: Files getting clobbered when I run out of disk space Anders Wegge Keller <wegge@wegge.dk> - 2013-01-08 09:16 +0100
Re: Files getting clobbered when I run out of disk space Jerry Stuckle <jstucklex@attglobal.net> - 2013-01-08 10:26 -0500
Re: Files getting clobbered when I run out of disk space "Twayne" <nobody@devnull.spamcop.net> - 2013-01-08 13:01 -0500
Re: Files getting clobbered when I run out of disk space "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2013-01-08 23:20 +0100
| From | faraz@squashclub.org |
|---|---|
| Date | 2013-01-07 15:49 -0800 |
| Subject | Files getting clobbered when I run out of disk space |
| Message-ID | <89d3884a-015f-42a7-910f-7c1c77ba68d9@googlegroups.com> |
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
[toc] | [next] | [standalone]
| From | Adam Harvey <usenet@adamharvey.name> |
|---|---|
| Date | 2013-01-08 01:07 +0000 |
| Message-ID | <kcfrha$cjg$1@dont-email.me> |
| In reply to | #8040 |
On Mon, 07 Jan 2013 15:49:30 -0800, faraz 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? Honestly, the right answer here is to set up a monitoring system that will alert you if disk space becomes low — trying to deal with this after the disk has already filled up is a bad idea, since at that point you've already lost the ability to write files, logs, database files et cetera. Trying to do this inline in a PHP script is the wrong tool for the job. Adam
[toc] | [prev] | [next] | [standalone]
| From | "Peter H. Coffin" <hellsop@ninehells.com> |
|---|---|
| Date | 2013-01-07 21:47 -0600 |
| Message-ID | <slrnken5m1.jfd.hellsop@nibelheim.ninehells.com> |
| In reply to | #8040 |
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
[toc] | [prev] | [next] | [standalone]
| From | Anders Wegge Keller <wegge@wegge.dk> |
|---|---|
| Date | 2013-01-08 09:16 +0100 |
| Message-ID | <87ehhwf5tr.fsf@huddi.jernurt.dk> |
| In reply to | #8040 |
faraz@squashclub.org writes:
> 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 functio
Use the disk_free_space() function instead. That will give you a
warning in advance, that you use to have your script send you a mail
about the situation.
You should also note that your file could end up being clobbered,
even in situations where you could write this test file. If your
payload would grow the file by more than one disk block, and there was
only one free, the dummy file would be written, but the capacity would
still be exceeded, when you write your actual data.
And finally, as have already been said: It's not the best of times to
handle a full disk, when you have data to write. It's of course better
to avoid loss of already existing data, but you really need to find a
way of avoiding a full disk in the first place.
--
/Wegge
Leder efter redundant peering af dk.*,linux.debian.*
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2013-01-08 10:26 -0500 |
| Message-ID | <kchdrj$9qn$1@dont-email.me> |
| In reply to | #8040 |
On 1/7/2013 6:49 PM, 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: > <snip code> I agree with Adam. When you're out of space is too late to detect it, and PHP is the wrong place to try. All of my servers monitor disk space (and other things) and send me an email when anything gets too far out of whack, even if the web server isn't running. It's all done with freely available tools at the OS level. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | "Twayne" <nobody@devnull.spamcop.net> |
|---|---|
| Date | 2013-01-08 13:01 -0500 |
| Message-ID | <kchmtp$el3$1@speranza.aioe.org> |
| In reply to | #8040 |
In news:89d3884a-015f-42a7-910f-7c1c77ba68d9@googlegroups.com,
faraz@squashclub.org <faraz@squashclub.org> typed:
> 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:
If you mean at the server end, there is nothing you can do about
it. It's their responsibility to keep enough space available to
you.
If you mean a local server, then it's your responsibility.
Either get rid of any quota or get/move it to a larger/another
drive with enough space.
I can't really see the problem - or how it's occurrng. Perhaps if
you provided enough details ...
HTH,
Twayne`
> /////////////////////////////
>
> 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
[toc] | [prev] | [next] | [standalone]
| From | "M. Strobel" <sorry_no_mail_here@nowhere.dee> |
|---|---|
| Date | 2013-01-08 23:20 +0100 |
| Message-ID | <al3kd7Fik9cU1@mid.uni-berlin.de> |
| In reply to | #8045 |
Am 08.01.2013 19:01, schrieb Twayne: > In news:89d3884a-015f-42a7-910f-7c1c77ba68d9@googlegroups.com, > faraz@squashclub.org <faraz@squashclub.org> typed: >> There was some disk space issues with my server. As a > If you mean at the server end, there is nothing you can do about > it. It's their responsibility to keep enough space available to > you. This reminds me of the MSwin administrators staring at the recurring error message "Ask your system administrator". /Str.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web