A puzzle! Crontab and mkdir and files, oh my!

Ralf Mardorf kde.lists at yahoo.com
Thu Apr 24 07:31:35 UTC 2025


On Thu, 2025-04-24 at 14:16 +1000, Karl Auer wrote:
> On Thu, 2025-04-24 at 14:01 +1000, Karl Auer wrote:
> > This is a crontab entry. I've broken it up over several lines for
> > clarity, but it's all one line in the crontab.
> > 
> > The first line is just saying "do this every day at 01:00".
> > 
> > The second line locates and deletes directories matching "*_temp*.
> >  
> > But what is going on in the last line?
> > 
> >    0 1 * * * 
> >    find /home/ubuntu/data -type d -name '*_temp*' -exec rm -r {} +
> >    > mkdir /home/ubuntu/data/log/adfd_cleanup.log 2>&1
> > 
> > Please - no theories! If you know, you know. And I don't know!
> 
> Now I do know.
> 
> I'll wait to tell you more in case the people that like a puzzle want
> to have a go at figuring it out. But I will leave a hint: The crontab
> line as a whole is badly broken.

Maybe the idea was to write stderr and/or stdout of "find" into the file
"adfd_cleanup.log" in combination with making the directory log/. If so,
one of several mistakes is, that "mkdir" would make "adfd_cleanup.log" a
directory instead of a file. You probably wanted to copy and paste the
path "/home/ubuntu/data/log/" from a terminal to the crontab, without
"mkdir" and without the redirection, but by accident you copied "mkdir
/home/ubuntu/data/log/adfd_cleanup.log 2>&1". In the terminal you maybe
run "mkdir /home/ubuntu/data/log/ > /dev/null 2>&1".



More information about the ubuntu-users mailing list