auto delete on size in dir called by cron

Post Reply
richard-g8jvm
Posts: 434
Joined: Sun Jan 18, 2015 1:27 am
languages_spoken: english
ODROIDs: C1+ C2, XU4
Location: Telford UK
Has thanked: 0
Been thanked: 3 times
Contact:

auto delete on size in dir called by cron

Post by richard-g8jvm »

Hi
I need to delete files generated by the program Motion that are less than say 800K and it needs to be called by cron
I could use something like ,
find . -size -800k -exec rm '{}' \;
I guess I could put that in a script
cd ~/Pictures/motion6
find . -size -800k -exec rm '{}' \;
The problem with HD cams is file size, and I've only got a 16GB eMMC card on the XU4, with 3GB spare
and flying insects at dusk and dawn drawn towards the IR leds
There doesn't seem to be a way in motion to ignore rapid movement, apart from movement for so many frames.
which doesn't work for an insect flying across the lens a few cms away, time to cross the lens aprox 50ms,, 1 frame
is about 67ms,
But always more than 1 insect !
as the files all are .avi
would may be this script
cd ~/Pictures/motion6
find . -type f -name '*.avi' -size -800k -exec rm {} \;
I'm not sure how to put this as a 1 line command which can be run by cron , instead of using cron to execute a script file
BR
Richard G8JVM

User avatar
meveric
Posts: 11357
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, H2 (N4100), N2, H2 (J4105), GoA, C4, GoA v1.1, H2+, HC4, GoS
Has thanked: 58 times
Been thanked: 443 times
Contact:

Re: auto delete on size in dir called by cron

Post by meveric »

richard-g8jvm wrote:
Wed Jan 13, 2021 7:09 pm

Code: Select all

cd ~/Pictures/motion6
find . -type f -name '*.avi'  -size -800k -exec rm {} \;
I'm not sure how to put this as a 1 line command which can be run by cron , instead of using cron to execute a script file
you can handle this in multiple ways.
1. use a script instead directly on command line
2. one liner: cd ~/Pictures/motion6 && find . -type f -name '*.avi' -size -800k -exec rm {} \;
3. without cd: find ~/Pictures/motion6 -type f -name '*.avi' -size -800k -exec rm {} \;

and probably many more ways to do it.

btw: ~/Pictures/motion6 is probably not a good way to define the path within cron. You should use the full path instead.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 2 guests