I'd like to write a cron - once a day delete folder - help?

Thanks I'll give it a try.

This is a learning curve for me. Takes me back to the DOS days when I knew so many commands by heart. The learning curve is a bit different for me today than it was in 1978. I tell my wife that the HD in my brain is getting full.

It is 8:32 AM and I gave the cron a time of 8:33 AM --- I'll see what happens.

It is 8:34 and I just looked --- it worked.

Thanks.


Didn't work? Hmmm, it should have deleted any files that were in ~/.thumbnails, but it would not have deleted any files in any sub-folders. If all of the files you wanted to delete were in sub-direcories of .thumbnail, that would explain the problem.

The tilde '~' character is an alias/short-cut for /home/yourusername/, so ~/.thumbnails should work. But you could try specifying the full path (e.g.
home/yourusername/.thumbnails) in your cron job, just in case the expansion of the tilde did not work.

BTW: DO NOT use ~/home/yourusername/.thumbnail/*, as a parameter to rm as this would expand to:
rm /home/yourusername/home/yourusername/.thumbnail/*
Not the end of the world, but the command would just fail as it expands to a path that does not exist.

And especially DO NOT put a space between the ~ and the rest of the path like this:
rm ~ /home/username/.thumbnail/* as this may result in dire consequences!

If you want to remove all of the files in .thumbnail and all files in its subdirectories, you could do it in one line using the find command like this:
Code:
15 0 * * * find /home/yourusername/.thumbnails/ -type f -delete
Use crontab -e to edit your existing job as per the above line of code! The cron job above will run every day at quarter past midnight (as per your last post) - so don't forget to change the date/time fields to suit your needs if you want it to run at a different time.

The find command used in the cron job above will find all file-system objects that are files, residing in the .thumbnails directory (or any of its sub-directories) and delete them. It will not affect any other files/folders outside of ~/.thumbnail/ and will not remove any symbolic links, sub-directories or other file-system objects that are inside ~/.thumbnail/.

Thinking about it, I should probably have suggested using find in the first place, rather than using rm! :oops: :rolleyes:
 


Now if only I could fix my odd video driver problem. I have Nvidia chipset and whenever I search for an answer, people point toward xorg file. Because of the age of my Nvidia card, I had to use the Nouveau driver. It has been a year but if I remember with the Nouveau driver no xorg file was created.

Sometimes when I log back in, my resolution goes haywire and i get extremely large icons / fonts so big that the screen gets split into two sections. What I must do is keep another user, log out, go to that user and change the display to 1280 X 800. The reason I must use another user is:

A: My user desktop can't be managed when the icons go crazy
B: Even if it is usable the choice to use 1280 X 800 may not be an available choice
C: The 1280 X 800 choice will be in the other user and that fixes things

Sometimes I need to do a shutdown and re-start to get the correct choice.

No probs, glad to have helped!
 

Staff online

Members online


Latest posts

Top