1753479 Members
5310 Online
108794 Solutions
New Discussion юеВ

cron job error

 
SOLVED
Go to solution
A.W.R
Frequent Advisor

cron job error

Hi,

I have inherited a Tru64UNIX system.

One of the cronjobs that it runs is:-

find /var/adm/syslog.dated/* -depth -type d -ctime +7 -exec rm -rf {} \;

Whenever this job runs root gets an e-mail with the error message - find: arg list too long

Is it possible that someone can advise where the error in this command is?

I have tried the man pages for find, and they seem to be a bit ambiguous.

Thanks
Andy

6 REPLIES 6
Rob Leadbeater
Honored Contributor
Solution

Re: cron job error

Hi Andy,

This is happening because there are too many files in the directory /var/adm/syslog.dated

You can usually get around it by using perl, rather than the rm, so something like this should work (although I haven't got a system to test on at the moment).

find /var/adm/syslog.dated/* -depth -type d -ctime +7 | perl -nle 'unlink;'

Hope this helps,

Regards,

Rob
Kapil Jha
Honored Contributor

Re: cron job error

Hi ,
ROb is perfect.This error is because you have a lot of files in var/adm/syslog.dated/
#ls -lrt /var/adm/syslog.dated|wc

generally syslog.dated does not have files for more than some days,u can go and delete old files,may be 500 at a time.
#find /var/adm/syslog.dated/* -depth -type d -ctime +7|head 500|xargs rm

BR,
Kapil
I am in this small bowl, I wane see the real world......
Kapil Jha
Honored Contributor

Re: cron job error

Check your syslog.conf , it may help you find out why there are so many files.
and see/tell what kind of files are accumulating.
BR,
Kapil
I am in this small bowl, I wane see the real world......
Ivan Ferreira
Honored Contributor

Re: cron job error

Also, I saw wrong behaviour with "-ctime" and should be replaced by "-mtime".

find /var/adm/syslog.dated/* -depth -type d -mtime +7 -exec rm -rf {} \;

Probably that is why you have too many directories.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Steven Schweda
Honored Contributor

Re: cron job error

> [...] where the error in this command is?

The shell expands "/var/adm/syslog.dated/*",
and the result is "too long".

Why not use
find /var/adm/syslog.dated [...]
instead of
find /var/adm/syslog.dated/* [...]
?

You might need to do something special to
avoid deleting the whole tree (when it
considers "/var/adm/syslog.dated" itself),
but that should be easy enough.

Using wildcard file specifications ("*")
always runs the risk of seeing too many
files.

> [...] may be 500 at a time.
> [...] |head 500| [...]

That's a bit too late, isn't it? "find" is
complaining, not "rm" (or the shell).
VINCENT, Jean-Marc
Valued Contributor

Re: cron job error

Hello Andy,

You can set exec_disable_arg_limit to 1 into proc subsystem to disable limit on the number of arguments that a command can have when it executes. It is recommended that you set exec_disable_arg_limit to 1.

see man sys_attrs_proc for exec_disable_arg_limit.

VINCENT Jean-Marc
HP France
Groupe Support Unix
Tru64(tm) UNIX Technical Consultant - Tru64(tm) UNIX Ambassador HP France
+33 1 5762-8861
jean-marc.vincent@hp.com
├п Think before you print