1831406 Members
3503 Online
110025 Solutions
New Discussion

exec problem

 
SOLVED
Go to solution
John Henrikson
Regular Advisor

exec problem

I've got a line in my crontab which suddenly isn't working correctly:
find /tmp/v_*.log ! -newer /tmp/last -exec rm {} ; touch /tmp/last > /dev/null 2>&1

It is giving me the error:
find: cannot access /tmp/last

Any ideas appreciated!
thanks!
John H.
6 REPLIES 6
Pete Randall
Outstanding Contributor

Re: exec problem

John,

How aobut permissions on /tmp/last? Since you touch it each time, has your umask changed?


Pete

Pete
nibble
Super Advisor

Re: exec problem

is /tmp/last existing? how about the permission?
John Henrikson
Regular Advisor

Re: exec problem

It does exist, I'm changing the permissions to see if that solves it thanks!
John H.
Steve Steel
Honored Contributor
Solution

Re: exec problem

Hi

/tmp/last is not there when script runs

That is the only cause


Find format
find / \( -name a.out -o -name '*.o' \) -atime +7 -exec rm {} \;

You do not have \; so also problem

Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
John Henrikson
Regular Advisor

Re: exec problem

It does exist, should I remove it?
I'm changing the permissions to see if that solves it thanks!
John H.
Muthukumar_5
Honored Contributor

Re: exec problem

hai,

If you are not having the file /tmp/last then find command cannot access the file and validate the /tmp/v*.log file weather it is not newer than the /tmp/last file.

Create the file first with touch then use the find command as like to validate the /tmp/v_*.log,

touch /tmp/last; find /tmp/v*.log ! - newer /tmp/last -exec rm {} > /dev/null 2>&1

It will work now.
Easy to suggest when don't know about the problem!