LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-30-2014, 07:29 PM   #1
redhatwannabe
Member
 
Registered: Dec 2008
Posts: 83

Rep: Reputation: 15
bash: /bin/ls: Argument list too long


Code:
oracle4@NODE01:~> ls -ld /u01/app/oracle4/diag/rdbms/orclee/ORCLEE1/trace/*.trc
bash: /bin/ls: Argument list too long
oracle4@NODE01:~>
I encountered this error after the a cron job is run successfully.

Code:
oracle4@NODE01:~> crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/home/oracle4/cronjob/cronjob_schedule.txt installed on Tue Dec 30 17:18:44 2014)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
MAILTO="yury@velikanov.com"
59 23 28-31 * * [ "$(/bin/date +\%d -d tomorrow)" = "31" ] && /home/oracle4/scripts/archive_alert_log/archive_alert_log.sh >&1

the contents of archive_alert_log is as follow


Code:
export CURRENT_USER=oracle4
export DB_BASE=/u01/app/$CURRENT_USER
export ORACLE_BASE=$DB_BASE
export ADR_BASE=$ORACLE_BASE
export PRODUCT_TYPE=rdbms
export PRODUCT_ID=orclee
export INSTANCE_ID=ORCLEE1
export SUBDIR=trace
export ADR_HOME=$ADR_BASE/diag/$PRODUCT_TYPE/$PRODUCT_ID/$INSTANCE_ID

export FIND=/usr/bin/find
export RM=/bin/rm
export MV=/bin/mv

export DAYS=+30

export HOME=/home/$CURRENT_USER

log_datetime="$(date +'%Y%m%d_%H%M%S')"

export DB_HOME=$DB_BASE/product/11.2.0.3/dbhome_1
export ORACLE_HOME=$DB_HOME
export NODENAME=node01
 
export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'

$MV $ADR_HOME/$SUBDIR/alert_$INSTANCE_ID.log $ADR_HOME/$SUBDIR/alert_$INSTANCE_ID.log_$log_datetime

$FIND $ADR_HOME/$SUBDIR/alert_$INSTANCE_ID.log_* -mtime $DAYS -exec rm {} \;

export SUBDIR=alert


$MV $ADR_HOME/$SUBDIR/log.xml $ADR_HOME/$SUBDIR/log.xml_$log_datetime

$FIND $ADR_HOME/$SUBDIR/log.xml_* -mtime $DAYS -exec rm {} \;

echo "$NODENAME $CURRENT_USER alert log has been archived."
how to I resolve this error?

many thanks in advance!
 
Old 12-30-2014, 07:39 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,341

Rep: Reputation: Disabled
Quote:
Originally Posted by redhatwannabe View Post
Code:
oracle4@NODE01:~> ls -ld /u01/app/oracle4/diag/rdbms/orclee/ORCLEE1/trace/*.trc
bash: /bin/ls: Argument list too long
oracle4@NODE01:~>
I encountered this error after the a cron job is run successfully.
The shell will attempt to expand the wildcard before passing the arguments to the command, but in this case it seems the wildcard simply expands to such a large number of files that the argument list exceeds what bash is capable of handling.

How many .trc files does the directory /u01/app/oracle4/diag/rdbms/orclee/ORCLEE1/trace/ contain?

Have you tried entering the directory first, and then run the command?
Code:
cd /u01/app/oracle4/diag/rdbms/orclee/ORCLEE1/trace
ls -ld *.trc
That will make each filename exactly 50 characters shorter, and that quickly adds up to a significant number of characters if there are lots of files.
 
1 members found this post helpful.
Old 12-30-2014, 08:46 PM   #3
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
You can use instead:

Code:
find /u01/app/oracle4/diag/rdbms/orclee/ORCLEE1/trace/ -maxdepth 1 -mindepth 1 -exec ls -ld "{}" \;
 
2 members found this post helpful.
Old 12-30-2014, 10:13 PM   #4
redhatwannabe
Member
 
Registered: Dec 2008
Posts: 83

Original Poster
Rep: Reputation: 15
Yes I was able to execute the command that you recommend to me

Code:
cd /u01/app/oracle4/diag/rdbms/orclee/ORCLEE1/trace
ls -ld *.trc

-rw-r----- 1 oracle4 asmadmin     1076 Dec 10 19:47 ORCLEE1_w000_9960.trc
-rw-r----- 1 oracle4 asmadmin     4300 Dec 10 09:05 ORCLEE1_w000_9961.trc
-rw-r----- 1 oracle4 asmadmin     1076 Dec 11 13:13 ORCLEE1_w000_9964.trc
-rw-r----- 1 oracle4 asmadmin     3227 Dec 11 00:13 ORCLEE1_w000_9966.trc
-rw-r----- 1 oracle4 asmadmin     1076 Dec 11 02:57 ORCLEE1_w000_9969.trc
-rw-r----- 1 oracle4 asmadmin     2148 Dec 11 03:22 ORCLEE1_w000_996.trc
-rw-r----- 1 oracle4 asmadmin     2151 Dec 10 19:14 ORCLEE1_w000_9971.trc
-rw-r----- 1 oracle4 asmadmin     3227 Dec 11 09:29 ORCLEE1_w000_9972.trc
-rw-r----- 1 oracle4 asmadmin     1076 Dec 11 05:42 ORCLEE1_w000_9974.trc
-rw-r----- 1 oracle4 asmadmin     1075 Dec  9 22:51 ORCLEE1_w000_9976.trc
-rw-r----- 1 oracle4 asmadmin     1075 Dec  9 20:15 ORCLEE1_w000_9977.trc
-rw-r----- 1 oracle4 asmadmin     3226 Dec 10 15:57 ORCLEE1_w000_9979.trc
-rw-r----- 1 oracle4 asmadmin     1073 Dec 10 02:33 ORCLEE1_w000_997.trc
-rw-r----- 1 oracle4 asmadmin     1075 Dec  9 20:41 ORCLEE1_w000_9980.trc
-rw-r----- 1 oracle4 asmadmin     2151 Dec 11 14:52 ORCLEE1_w000_9981.trc
-rw-r----- 1 oracle4 asmadmin     1075 Dec 10 03:32 ORCLEE1_w000_9982.trc
-rw-r----- 1 oracle4 asmadmin     1076 Dec 11 12:11 ORCLEE1_w000_9983.trc
-rw-r----- 1 oracle4 asmadmin     1075 Dec  9 18:56 ORCLEE1_w000_9984.trc
-rw-r----- 1 oracle4 asmadmin     1076 Dec 10 15:24 ORCLEE1_w000_9987.trc
-rw-r----- 1 oracle4 asmadmin     1075 Dec  9 22:00 ORCLEE1_w000_9988.trc
I was also able to execute find /u01/app/oracle4/diag/rdbms/orclee/ORCLEE1/trace/ -maxdepth 1 -mindepth 1 -exec ls -ld "{}" \;

Code:
find /u01/app/oracle4/diag/rdbms/orclee/ORCLEE1/trace/ -maxdepth 1 -mindepth 1 -exec ls -ld "{}" \;

-rw-r----- 1 oracle4 asmadmin 1075 Dec  9 23:38 /u01/app/oracle4/diag/rdbms/orclee/ORCLEE1/trace/ORCLEE1_m000_4244.trc
-rw-r----- 1 oracle4 asmadmin 349 Dec 11 07:55 /u01/app/oracle4/diag/rdbms/orclee/ORCLEE1/trace/ORCLEE1_j000_14900.trm
-rw-r----- 1 oracle4 asmadmin 63 Dec 11 08:02 /u01/app/oracle4/diag/rdbms/orclee/ORCLEE1/trace/ORCLEE1_j000_21311.trm
-rw-r----- 1 oracle4 asmadmin 1415 Dec 17 06:21 /u01/app/oracle4/diag/rdbms/orclee/ORCLEE1/trace/ORCLEE1_gcr0_1587.trc
-rw-r----- 1 oracle4 asmadmin 205 Dec 11 04:41 /u01/app/oracle4/diag/rdbms/orclee/ORCLEE1/trace/ORCLEE1_w000_14040.trm
-rw-r----- 1 oracle4 asmadmin 5105 Dec 11 12:59 /u01/app/oracle4/diag/rdbms/orclee/ORCLEE1/trace/ORCLEE1_j000_28418.trc
What was actually the cause of the error? the number of files or the length of the directory I'm passing to the ls -lrt?

thanks a lot!
 
Old 12-30-2014, 10:46 PM   #5
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,341

Rep: Reputation: Disabled
Quote:
Originally Posted by redhatwannabe View Post
What was actually the cause of the error? the number of files or the length of the directory I'm passing to the ls -lrt?
The root cause is that the the path length for each file combined with the number of files in the base directory resulted in a list of command line arguments that was simply too long.

bash expanded the wildcard into a string of characters that turned out to be too long for it to handle, so it reported an error. Because of this, the ls command was never actually invoked.
 
1 members found this post helpful.
  


Reply

Tags
bash



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
-bash: /bin/: Argument list too long zeeshan673 Linux - General 4 02-22-2007 10:25 AM
bash: /bin/ls: Argument list too long. Workaround? Kropotkin Linux - General 3 02-28-2006 11:45 AM
bash: /bin/rm: Argument list too long? FiveFlat Linux - General 5 08-11-2004 11:29 PM
-bash: /bin/mv: Argument list too long balanagireddy Linux - General 2 07-27-2004 11:19 PM
/bin/rm: Argument list too long dragon49 Linux - Software 1 09-02-2003 12:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:35 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration