LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 11-26-2009, 01:09 PM   #1
RasmusThomsen
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Rep: Reputation: 0
Finding the latest file - "broken pipe" error


HI everyone,

I am using the following script to find the latest .jpg file among around 50.000 files:

$file = exec("ls -t /home/ftp/$account | grep .jpg$ -i | head -n 1");

The script works, but multiple "broken pipe" errors occur in the Apache error.log. The log file is around 100GB.

I am almost sure that the above listed script is the troublemaker. Therefore I would like to know a better way to do the same thing.

Distribution: Debian (lenny).

Thanks in advance, Rasmus
 
Old 11-26-2009, 01:25 PM   #2
18Googol2
Member
 
Registered: Oct 2008
Distribution: FreeBSD, RedHat, Centos, Solaris, AIX
Posts: 34

Rep: Reputation: 17
Try this:

ls -1t *.mp3 | head -1
 
Old 11-26-2009, 01:25 PM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Hi,

A (ascii) logfile of 100Gb is, well "a bit over the top". Some programs will have problems with a file this big, others will take big bites out of your resources and some won't work at all. This also depends on (amounts of) hardware, linux/unix and/or distro used.

Your first priority should be taking care of the logfile(s). Take a look at logrotate.

You don't mention which linux distro you use, so I cannot point you in the specific direction. Feed your search-engine with "linux logrotate apache" to get going (maybe add your distro).

Hope this helps.
 
Old 11-30-2009, 04:04 PM   #4
RasmusThomsen
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks for your answers. I changed the command to ls -tr | tail -1 and the broken pipe error disappeared.
 
  


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
Problem "$value=`mpstat 1 1 | grep "Average"`;" Alias pipe return nothing adamlucansky Linux - General 8 09-25-2009 07:26 AM
Downloaded rar file, tried to open with 7Zip, getting "file is broken" message? Ejfel Linux - Software 7 03-02-2009 12:51 AM
"broken pipe" in installing Ndiswrapper joshknape Linux - Newbie 0 02-14-2006 11:27 PM
ifconfig usb0 produces "Broken pipe" JohnKFT Slackware 0 11-13-2004 04:56 PM
"broken pipe" with FTP compu73rg33k Linux - Networking 8 02-27-2004 03:40 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration