Home > Blockchain >  Crontab to delete files
Crontab to delete files

Time:06-02

I´m very new to Linux, and right now I am trying to delete some video recordings of my security camera (from the FTP server) at every 30 minutes.

I already used: pi@raspberrypi:~$ find path/toMy/Video/recordings/ -type f -mmin 30 -delete

After that, I used crontab -e choose the Nano option and typed:

*/30 * * * * find path/toMy/Video/recordings/ -type f -mmin 30 -delete

Saved it, but it doesn´t seem to work. What am I doing wrong?

CodePudding user response:

Make sure you use the full path to find, for example:

% which find
/usr/local/opt/findutils/libexec/gnubin/find

Also, use absolute path (not relative path) for your directory.

Then:

*/30 * * * * /usr/local/opt/findutils/libexec/gnubin/find /path/toMy/Video/recordings/ -type f -mmin  30 -delete

CodePudding user response:

To debug:

  1. You can also redirect the output of your crontab entry.
*/30 * * * * find path/toMy/Video/recordings/ -type f -mmin  30 -delete &> /<your-path>/cron.out
  1. Check for the cron logs in /var/log/
  • Related