Page 1 of 1

error when running job in crontab "find: missing argument to `-execdir' "

Posted: Fri Oct 18, 2019 7:22 am
by doubleudee1
I am running a few jobs (successfully) in my crontab and have decided to try and remove files and folders off my hard disk that are older than a certain time so the disk does not fill up like an earlier disk I set up did.
I have the line:-

Code: Select all

#### first jpg files #####
1 1 * * * find /home/pi/mnt/CamFiles/FrontOfHouse/jpgFiles -type f -mtime +90 -name '*.jpg' -execdir -rm -- '{}'$ >> /home/pi/jpgFilesRemovedF.txt 2>&1
#### next jpg Dirs #####
1 2 * * * find /home/pi/mnt/CamFiles/FrontOfHouse/jpgFiles -depth -type d -mtime +90 --execdir -rmdir -- '{}'$ >> /home/pi/jpgDirsRemovedF.txt 2>&1
#### first mp4 files #####
1 3 * * * find /home/pi/mnt/CamFiles/RearOfHouse/jpgFiles -type f -mtime +90 -name '*.jpg' -execdir - rm -- '{}'$ >> /home/pi/jpgFilesRemovedR.txt 2>&1
#### next mp4 Dirs #####
1 4 * * * find /home/pi/mnt/CamFiles/RearOfHouse/jpgFiles -depth -type d --execdir -rmdir -- '{}'$ >> /home/pi/mp4DirsRemovedR.txt 2>&1
but I find it gives me the error "find: missing argument to `-execdir' being generated?

I've done a few searches but nothing concrete seems to come up, I am having the same result if I try and remove directories?

any ideas/pointers please, as 'man crontab' is just confusing to me?

Thanks

Re: error when running job in crontab "find: missing argument to `-execdir' "

Posted: Fri Oct 18, 2019 9:06 am
by Pulsar33
Hello,

Try this :

Code: Select all

1 1 * * * find /home/pi/mnt/CamFiles/FrontOfHouse/jpgFiles -type f -mtime +90 -name '*.jpg' -execdir -- rm '{}'$ >> /home/pi/jpgFilesRemovedF.txt 2>&1
BR
Pulsar33

Re: error when running job in crontab "find: missing argument to `-execdir' "

Posted: Fri Oct 18, 2019 9:25 am
by doubleudee1
Pulsar33 wrote:
Fri Oct 18, 2019 9:06 am
Hello,

Try this :

Code: Select all

1 1 * * * find /home/pi/mnt/CamFiles/FrontOfHouse/jpgFiles -type f -mtime +90 -name '*.jpg' -execdir -- rm '{}'$ >> /home/pi/jpgFilesRemovedF.txt 2>&1
BR
Pulsar33
Sorry, got this:-

Code: Select all

-bash: 1: command not found
find: missing argument to `-execdir'
Seems the same fault?

Re: error when running job in crontab "find: missing argument to `-execdir' "

Posted: Fri Oct 18, 2019 10:07 am
by B.Goode
You appear to be inconsistent in your use of -execdir and --execdir. Might that be significant?

Re: error when running job in crontab "find: missing argument to `-execdir' "

Posted: Fri Oct 18, 2019 10:19 am
by rpdom
Try putting this version in your crontab:

Code: Select all

1 1 * * * find /home/pi/mnt/CamFiles/FrontOfHouse/jpgFiles -type f -mtime +90 -name '*.jpg' -execdir rm {} \; >> /home/pi/jpgFilesRemovedF.txt 2>&1

Re: error when running job in crontab "find: missing argument to `-execdir' "

Posted: Fri Oct 18, 2019 12:39 pm
by doubleudee1
rpdom wrote:
Fri Oct 18, 2019 10:19 am
Try putting this version in your crontab:

Code: Select all

1 1 * * * find /home/pi/mnt/CamFiles/FrontOfHouse/jpgFiles -type f -mtime +90 -name '*.jpg' -execdir rm {} \; >> /home/pi/jpgFilesRemovedF.txt 2>&1
This is what I find in my txt file running that:-

-bash: 1: command not found

?????????????????

Re: error when running job in crontab "find: missing argument to `-execdir' "

Posted: Fri Oct 18, 2019 12:55 pm
by doubleudee1
B.Goode wrote:
Fri Oct 18, 2019 10:07 am
You appear to be inconsistent in your use of -execdir and --execdir. Might that be significant?
yes, I see that now so I have changed them all to --execdir, is that correct or should it be -execdir?

Re: error when running job in crontab "find: missing argument to `-execdir' "

Posted: Fri Oct 18, 2019 1:05 pm
by doubleudee1
OK, thanks both.
It looks like a combination of errors in my script using -- after -execdir, and also using --execdir, instead of -execdir.

All changed now a no errors came back from running them.

Thanks again.