Results 1 to 5 of 5

Thread: cronjob to delete

  1. #1
    Join Date
    Sep 2007
    Location
    USA
    Beans
    Hidden!

    cronjob to delete

    I'd like to set up a cronjob to delete unnecessary files. Where is the trash bin located in the file directory and are there any other directories that store temporary stuff (besides the /tmp folder and any download folder I created)?

    What can I set to delete that won't fry the system besides user created files?

  2. #2
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: cronjob to delete

    User trash in hardy is stored in /home/username/.local/share/Trash/files

    Previous versions stored trash in ~/.Trash

    Use a bit of caution about deleting the tmp folder as the files could be in use during a session. You wouldn't want to set a cronjob that ran at a specific time unless you were sure none of the information from the tmp files was still in use.
    Last edited by drs305; July 8th, 2008 at 07:58 PM.

  3. #3
    Join Date
    Jan 2008
    Beans
    4,757

    Re: cronjob to delete

    The trash is located in ~/.local/share/Trash

    A nice script to remove and recreate the directory would be
    Code:
    for i in /home/*
    do cat /etc/passwd | grep $i
       if [ $? -eq 0 ]
       then rm -rf /home/$i/.local/share/Trash
            mkdir -p /home/$i/.local/share/Trash/files/../info
            echo "removed trash folder for $i"
       else echo "$i not a user"
       fi
    done
    Other things you can search and destroy are flush/temp files such as foo~ and #foo#.

    Code:
    find /home -type f -iname "*~" -exec rm "{}" \;
    find /home -type f -iname "#*#" -exec rm "{}" \;
    other possible temp files include *.bak *.tmp and *.log, but whether or not you want to delete them too is arguable.

    Two other folders that are safe to remove (usually not needed/not used) are:
    Code:
    ~/.cache
    ~/.thumbnails
    Although, they have now been fixed to have a small footprint on your hard drive space (.thumbnails in Gutsy would take up 300MB+ after 3 months) so they are probably worth ignoring now.

    Other than that, there really isn't much more that you can remove.
    Are you really struggling to keep hard drive space?

    Regards
    Iain

  4. #4
    Join Date
    Sep 2007
    Location
    USA
    Beans
    Hidden!

    Re: cronjob to delete

    I'm not struggling in the least (300 gigs about using only 2.something) I just want to automate deleting stuff. Thanks.

  5. #5
    Inxsible's Avatar
    Inxsible is offline Badabing Badabang Badaboom...Sucker!
    Join Date
    Feb 2006
    Beans
    4,996

    Re: cronjob to delete

    I would advise against deleting stuff using crons. Deleting often requires user input...and that is supposed to be read and understood by the user and then take appropriate action.

    No point in having the cron screw up a system.

    That being said, if you are only going to use cron to delete user data...you may as well use Shift + Del while deleting stuff as opposed to a simple Del
    Shed that weight!! -- Apps | Window Managers

    Arch + i3 (tty1) Arch + wmfs (tty2)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •