ls is being killed


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users ls is being killed
# 1  
Old 02-19-2008
ls is being killed

Hi There,

Hope anyone can give me a hand on AIX

oslevel -r
5300-05

Try to "ls *sh" from folder and it return killed, is there any clue on that?

1. perform ls and count
ls * | wc -l
0
ksh: 561582 Killed


2. without provide "*" wildcard, the result can be return
ls | wc
273 273 6383


3. ulimit setting
ulimit -a
time(seconds) unlimited
file(blocks) unlimited
data(kbytes) unlimited
stack(kbytes) unlimited
memory(kbytes) unlimited
coredump(blocks) unlimited
nofiles(descriptors) 8196
# 2  
Old 02-19-2008
May I ask you how many files are in that directory?
I may be you reached the maximum argument a command (here ls) can take
A workaround is to use | xargs
# 3  
Old 02-19-2008
Quote:
Originally Posted by vbe
May I ask you how many files are in that directory?
I may be you reached the maximum argument a command (here ls) can take
A workaround is to use | xargs
This is exactly what is happening.
# 4  
Old 02-19-2008
Quote:
Originally Posted by vbe
May I ask you how many files are in that directory?
I may be you reached the maximum argument a command (here ls) can take
A workaround is to use | xargs
it is only 273 files inside the directory, what is the limit?
# 5  
Old 02-20-2008
Probably system is compromised. Usually this is symptom of "root-kit". Or hacker may have changed some libraries
# 6  
Old 02-20-2008
Does this still happen when using options? Such as ls -l for example.
# 7  
Old 02-20-2008
Quote:
Originally Posted by darkrainbow
it is only 273 files inside the directory, what is the limit?
The problem is not a filesystem limit, the problem is a commandline limit: when you enter a command with a (shell-)variable or wildcard, like you entered "ls -l *sh" then the shell will expand the wildcard to all the filenames it is representing. Only then it will call the binary (ls in this case) and feed it whatever the wildcard has expanded to.

Example:

Code:
# ls -l
total 55
-rwxr-xr--   1 root     system        20455 Jan 08 12:03 a.sh
-rw-------   1 root     system         2527 Dec 08 2006  b.sh
-rwxr-xr--   1 root     system         5617 Feb 20 13:24 c.sh

We enter a command:

Code:
# ls -l *sh

Now, before giving the command to ls, the shell looks up what "*sh" represents and expands that to "a.sh b.sh c.sh". The command line now looks like:

Code:
# ls -l a.sh b.sh c.sh

Only now "ls" is called and fed the rest of the command line.

Alas, command lines cannot grow ad infinitum. POSIX has a limit of 4k characters and exactly this limit is exceeded in your case as the last value in your output of wc (the number of characters) shows. This is a pretty common gotcha in shell scripting and the common solution is to avoid constructions like that and use "find" instead. Your command above could be safely written this way:

Code:
find . -type f -name "*sh" -print | wc -l

I hope this helps.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. What is on Your Mind?

Has Oracle killed HP-UX

Has Oracle killed HP-UX with their gambit of telling the public they would no longer support Itanium? The company I work for in the Dallas, TX area has had several openings for HP-UX administrators and we're having such a tough time finding qualified people to fill them. I have been searching job... (3 Replies)
Discussion started by: keelba
3 Replies

2. UNIX for Dummies Questions & Answers

Process Killed : Need to find why ?

Hi reader, I'm making a tool out of korn shell script that is running on a HP-UX server. But everytime i invoke the tool, it gets killed after a while (mid-process). I have tried re-running it a couple of times but each invocation ending up the same way .. following is a snippet of the o/p... (8 Replies)
Discussion started by: clakkad
8 Replies

3. Shell Programming and Scripting

Syncsort is getting killed

Hi All, I am running synsort utility via unix scripts. As soon as the control reaches the syncsort command,Its getting killed. The error message is /proj/cdw/syncsort/dev/copay/CdwWkRvrslFileReformat.syn: 8339696 Killed . Please suggest to overcome this issue. (5 Replies)
Discussion started by: prashantnandi
5 Replies

4. Shell Programming and Scripting

command to use if someone killed the script in between?

Hi All, I want to know about what command i can use so that it should run the below mentioned line if somebody killed the process when i run my script... the command to run once my script is killed is \rm -rf $LOCKDIR Thank you (2 Replies)
Discussion started by: smarty86
2 Replies

5. Solaris

how to run a killed process

hi, i am creating a daemon process for updating the file at regular interval.one problem with this is if anybody kills the daemon it wont update the file.anybody have idea how to rerun the daemon if it killed.the code is written in c++ in solaries environment. thnaks & regards suresh (8 Replies)
Discussion started by: suresh_rtp
8 Replies

6. Shell Programming and Scripting

Killed by signal 15.

Hi all I have Master script, Main script ,and 4 Child script. Master.sh #!/bin/bash /export/home/user/Main.shMain.sh #!/bin/bash /export/home/user/Child1.sh & /export/home/user/Child2.sh & /export/home/user/Child3.sh & /export/home/user/Child4.sh &I run only Master.sh script... (1 Reply)
Discussion started by: almanto
1 Replies

7. UNIX for Advanced & Expert Users

Getting 'Killed' msg

Can anyone explain? I start my unix session on AIX, run tcsh move to a particular directory, let say: cd /test/bin and next i run a command like: grep "test string" /test/bin/* to look for the string in any files in the directory. I am getting a response of Killed. Why is that... (16 Replies)
Discussion started by: gio001
16 Replies

8. Solaris

Port used needs to be killed

Hi, We are using oracle 10g in a Solaris box. The same box has Informatica also installed. But it runs on port 6001. But whenever the server is restarted the Oracle database picks up the port 6001 and does not allow Informatica to be started. But I am have no clue of which Oracle process is... (2 Replies)
Discussion started by: chrisanto_2000
2 Replies

9. UNIX for Dummies Questions & Answers

I'm getting killed and I don't know why.

UPDATE: I think I may have a culprit. I had KDE console history to unlimited, and since there's a lot of output... I'm thinking that may be it. I'd still like to hear advice on how to figure out why processes get killed, if anyone has any! though ****************** There's this script I run... (1 Reply)
Discussion started by: tphyahoo
1 Replies

10. UNIX for Dummies Questions & Answers

process not getting killed

I have a process that is in the sleeping state "S" and I have tried to stop it with a run control script that I use to stop/start it - but it does not stop. I have tried kill -9 <PID of process> with no change. I imagine that this process is sleeping with the kernel. It does not respond to... (5 Replies)
Discussion started by: finster
5 Replies
Login or Register to Ask a Question