Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to making crontab files and I decided to try and make a job that would delete the contents of my Downloads folder, and then empty the trash. This is what I have:

0 9 * * *   rm $HOME/Downloads/*.*
10 9 * * *  rm -rf ~/.Trash/*

Is this safe to run? I've heard a lot of talk on using the rm command wisely. Is it even necessary to remove the trash or does rm skip the trash?

share|improve this question
up vote 2 down vote accepted

To answer your questions:

Is this safe to run?

Depends on your definition of "save". It will not wreak havoc, but I wouldn't recommend it.

... does rm skip the trash?

The rm command skips the trash. rm doesn't even know about the concept of recycle bin. Virtually all command line commands have no idea about the concept of recycle bin (some oddballs think it is fun to have a terminal based recycle bin).

If you insist on a cron job to clear your download directory I would recommend doing it like this:

find $HOME/Downloads/ -mtime +1 -delete

This will delete all files (and directories) older than one day. Otherwise, if you downloaded something on 8:59, it will get deleted right away.

Note: under linux the wildcard *.* means something else than under windows. I assume you come from the windows world where *.* means every file.


$ ls
$ echo *
$ echo *.*
$ echo *.*.*
$ echo *..*

* gets expanded to everything, including ., except a leading ., but that is an entirely different story. *.* gets expanded to everything which has at least one dot in the middle. *.*.* gets expanded to everything which has two dots. I think you get the idea, the dot doesn't have any special meaning in filename expansion. Be carefull though, the dot has a very special meaning when dealing with regular expressions, but that is also an entirely different story.

share|improve this answer
OH right, my bad. I've been using linux for a long time but I've never done much bash stuff. Thanks for your suggestion, I'll definitely use that. – n0pe Apr 20 '11 at 19:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.