doubleudee1
Posts: 158
Joined: Fri Nov 30, 2018 2:39 pm
Location: Wales

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

Fri Oct 18, 2019 7:22 am

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
Make the most of your family and friends , your children grow up too quickly and you don't notice yourself ageing, friends dissapearing, moving on. You make plans for your future, but they can all be smashed in an instant, live life and enjoy. :)

User avatar
Pulsar33
Posts: 112
Joined: Sun Aug 25, 2019 4:06 pm
Location: Bordeaux France

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

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
Pi 4 with 4Gb memory, DVB TV pHAT ------------------- Desktop : Core i5 Linux MINT 19.2

doubleudee1
Posts: 158
Joined: Fri Nov 30, 2018 2:39 pm
Location: Wales

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

Fri Oct 18, 2019 9:25 am

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?
Make the most of your family and friends , your children grow up too quickly and you don't notice yourself ageing, friends dissapearing, moving on. You make plans for your future, but they can all be smashed in an instant, live life and enjoy. :)

User avatar
B.Goode
Posts: 8987
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

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

Fri Oct 18, 2019 10:07 am

You appear to be inconsistent in your use of -execdir and --execdir. Might that be significant?

User avatar
rpdom
Posts: 15575
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

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

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

doubleudee1
Posts: 158
Joined: Fri Nov 30, 2018 2:39 pm
Location: Wales

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

Fri Oct 18, 2019 12:39 pm

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

?????????????????
Make the most of your family and friends , your children grow up too quickly and you don't notice yourself ageing, friends dissapearing, moving on. You make plans for your future, but they can all be smashed in an instant, live life and enjoy. :)

doubleudee1
Posts: 158
Joined: Fri Nov 30, 2018 2:39 pm
Location: Wales

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

Fri Oct 18, 2019 12:55 pm

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?
Make the most of your family and friends , your children grow up too quickly and you don't notice yourself ageing, friends dissapearing, moving on. You make plans for your future, but they can all be smashed in an instant, live life and enjoy. :)

doubleudee1
Posts: 158
Joined: Fri Nov 30, 2018 2:39 pm
Location: Wales

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

Fri Oct 18, 2019 1:05 pm

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.
Make the most of your family and friends , your children grow up too quickly and you don't notice yourself ageing, friends dissapearing, moving on. You make plans for your future, but they can all be smashed in an instant, live life and enjoy. :)

Return to “Troubleshooting”