0

I'm trying to solve a problem with rotating binary files.

I have video files which are recorded from IP camera, and I want to delete oldest files when I have less then e.g. 10 Gb of free space.

Files are named in %Y%m%d%H%M%S.h264 format, for example 20150624123600.h264.

First I was thinking of using logrotate for that, but with config

/data/video/.h264 {
    rotate 20
    nocompress
    dateext
    dateformat %Y%m%d%H%M%S
    extension .h264
    missingok
}

I get message log /data/video/.h264 does not exist -- skipping while files like /data/video/20150624123600.h264 are exist. I also tried to add prefix, but it didn't help.

Could you help me with solving this problem - deleting oldest files (according to the date in file name) when free space limit is reached? It could be just bash script or logrotate config, or anything that could be run on ubuntu server.

dds
  • 639
  • 6
  • 15
  • 2
    Just use `/data/video/*.h264`to solve your initial problem..regarding your new question, after how many rotations the file will be deleted ? also note that AFAIK its not possible to take any decision based on the free space of the computer in `logrotate` although you can use `size` parameter of `logrotate` to rotate files greater than a certain size.. – heemayl Jul 02 '15 at 12:16

1 Answers1

-1

You find a very detailed answer here in the second reply.

Limit the size of a directory by deleting old files

to access cron you should type

crontab -e
sboda
  • 512
  • 2
  • 9