Discussion:
deleting /tmp files from crontab
(too old to reply)
david+dated+ (David Banning)
2016-04-26 12:30:13 UTC
Permalink
I am attempting to delete my .spamassassin files from my /tmp directory

putting a command in my crontab;

find /tmp/.spam* -mmin +360 -delete

renders the following error;

find: -delete: /tmp/.spamassassin10101hXUUVytmp: relative path potentially not safe

looking in past postings on this matter, post people add the -mindepth 1, however in my case while it elliminates the error,
it does not delete all the files, perhaps because some of the .spam* files are directories.

I wonder if someone has a solution for this.
david+dated+ (David Banning)
2016-04-26 14:13:02 UTC
Permalink
Post by david+dated+ (David Banning)
I am attempting to delete my .spamassassin files from my /tmp directory
putting a command in my crontab;
find /tmp/.spam* -mmin +360 -delete
the find syntax looks strange (assuming this is straight 'find', not
somthing crontab-specific); normally, I'd expect to see
# find /tmp -name '.spam*' -mmin +360 -delete
That seems to delete the files, but not the directories starting in .spam*

Reviewing the find man page, it appears the -delete implementation will
not work unless the directory is empty. Still looking for solutions here.
Does that help?
regards
Michael
Post by david+dated+ (David Banning)
renders the following error;
find: -delete: /tmp/.spamassassin10101hXUUVytmp: relative path potentially
not safe
looking in past postings on this matter, post people add the -mindepth 1,
however in my case while it elliminates the error,
it does not delete all the files, perhaps because some of the .spam*
files are directories.
I wonder if someone has a solution for this.
_______________________________________________
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to
--
Michael Schuster
http://recursiveramblings.wordpress.com/
recursion, n: see recursion
William A. Mahaffey III
1970-01-01 00:00:00 UTC
Permalink
Post by david+dated+ (David Banning)
Post by david+dated+ (David Banning)
I am attempting to delete my .spamassassin files from my /tmp directory
putting a command in my crontab;
find /tmp/.spam* -mmin +360 -delete
the find syntax looks strange (assuming this is straight 'find', not
somthing crontab-specific); normally, I'd expect to see
# find /tmp -name '.spam*' -mmin +360 -delete
That seems to delete the files, but not the directories starting in .spam*
Reviewing the find man page, it appears the -delete implementation will
not work unless the directory is empty. Still looking for solutions here.
Perhaps a 2nd invocation replacing '-delete' w/ '-exec \rm -rf {} +' ?
--
William A. Mahaffey III

----------------------------------------------------------------------

"The M1 Garand is without doubt the finest implement of war
ever devised by man."
-- Gen. George S. Patton Jr.
Timo Buhrmester
2016-04-26 14:30:00 UTC
Permalink
Post by david+dated+ (David Banning)
# find /tmp -name '.spam*' -mmin +360 -delete
That seems to delete the files, but not the directories starting in .spam*
Reviewing the find man page, it appears the -delete implementation will
not work unless the directory is empty. Still looking for solutions here.
A common idiom is ``find ... -print0 | xargs -0 rm -r''.
Note that -print0 and xargs -0 aren't POSIX, but I'm not aware of
implementations lacking those.
Arthur Chance
2016-04-26 14:23:24 UTC
Permalink
Post by david+dated+ (David Banning)
Post by david+dated+ (David Banning)
I am attempting to delete my .spamassassin files from my /tmp directory
putting a command in my crontab;
find /tmp/.spam* -mmin +360 -delete
the find syntax looks strange (assuming this is straight 'find', not
somthing crontab-specific); normally, I'd expect to see
# find /tmp -name '.spam*' -mmin +360 -delete
That seems to delete the files, but not the directories starting in .spam*
Reviewing the find man page, it appears the -delete implementation will
not work unless the directory is empty. Still looking for solutions here.
Take a look at the -d or argument-less -depth primaries. From the man page

-depth Always true; same as the non-portable -d option. Cause find to
perform a depth-first traversal, i.e., directories are visited in
post-order and all entries in a directory will be acted on before
the directory itself.
--
Moore's Law of Mad Science: Every eighteen months, the minimum IQ
necessary to destroy the world drops by one point.
Loading...