- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Parameter list is too long.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-29-2005 11:46 PM
тАО09-29-2005 11:46 PM
I have a Script that removes logs with "x" days in a directory of my HPUX 11i server.
The logs are generated following a standard:
Dxx_LOG_NAME.log, where xx is the number of days we have to retain the log.
The scripts is this:
DAY=$(ls -1 /interface/web/D* |cut -f2 -dD |cut -f1 -d_)
NEW=00
for EACHONE in $DAY
do
if [ "${NEW}" -ne "${EACHONE}" ]; then
NEW=$EACHONE
EACHONE=`expr $EACHONE \* 1`
EACHONE=`expr $EACHONE - 1`
find /interface/web/ -name D$NEW*.* -mtime +$EACHONE -print -exec rm {} \;
fi
done
----------------------------------------------------------
Sometimes I'm receiving this message:
sh: /usr/bin/ls: The parameter list is too long.
Do you Know How can I avoid it?
Thanks,
Rafael
Solved! Go to Solution.
- Tags:
- Arg list too long
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-29-2005 11:54 PM
тАО09-29-2005 11:54 PM
Re: Parameter list is too long.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2005 12:03 AM
тАО09-30-2005 12:03 AM
Re: Parameter list is too long.
while read -r filename
do
rm -f $filename
# or any other operation you want to accomplish.
done < file
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2005 12:07 AM
тАО09-30-2005 12:07 AM
Re: Parameter list is too long.
You are causing the shell to collect create a list that is too long. Change the way you drive your script to leverage the 'find' of the directory, like:
...
cd /interface/web
find . -type f |
while read FILE
do
...
done
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2005 12:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2005 12:27 AM
тАО09-30-2005 12:27 AM
Re: Parameter list is too long.
Although the other posts would work, RAC mentioned the correct answer:
DAY=$(ls -1 /interface/web/D* |cut -f2 -dD |cut -f1 -d_)
NEW=00
for EACHONE in $DAY
do
if [ "${NEW}" -ne "${EACHONE}" ]; then
NEW=$EACHONE
EACHONE=`expr $EACHONE \* 1`
EACHONE=`expr $EACHONE - 1`
find /interface/web/ -name D$NEW*.* -mtime +$EACHONE -print | xargs -i rm {}
fi
done
The trick is the xargs pipe from the find command. Minor tweak.
HTH;
Doug
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2005 12:33 AM
тАО09-30-2005 12:33 AM
Re: Parameter list is too long.
I'd still keep the xargs command in your loop; however, you can avoid the potential buffer overflow by:
NEW=00
for EACHONE in $(find /interface/web -name D\* -exec ls -dl {} \; | cut -f2 -dD | cut -f1 -d_)
do
if [ "${NEW}" -ne "${EACHONE}" ]; then
NEW=$EACHONE
EACHONE=`expr $EACHONE \* 1`
EACHONE=`expr $EACHONE - 1`
find /interface/web/ -name D$NEW*.* -mtime +$EACHONE -print | xargs -i rm {}
fi
done
Sorry for the confusion...
Doug
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-30-2005 12:37 AM
тАО09-30-2005 12:37 AM
Re: Parameter list is too long.
It's Working!