I think each of us has the “Disassemble” and “Downloads” directories, looking into which we are all terrified by their contents, and especially by the very idea that someday this will have to be raked. I offer my own solution to the problem of lack of space, this is not a way of supersarching, and not a way of endlessly building up a place anywhere in the cloud, just an idea to organize the downloaded information.

What is the probability that if the file was not remembered within 2 weeks, it will be remembered in a year or two, despite the fact that almost everything downloaded on the Internet tends to quickly become obsolete. This solution is also suitable for the organization of shared resources (file dumpsters).
It is not always possible to listen to the album, an unknown group, interested only in the fact that this music was attributed to the favorite genre, usually two solutions remain. In the first case, the album gets into the “Disassemble” directory / remains in “Downloads”, which is called later, how quickly these directories swell up is known to all. In the second case, the album is stored in a specially designated “Music” directory, constantly building it up, but as a result, at some point it comes to the understanding that this is not the place where your favorite and selected performers are stored, but the same “Disassemble” directory, in which the sorting by sound files is performed.
The same with movies, books, wallpapers, with any documents. You can download to succumb to the emotions, recommendations, beautiful cover, but whether this film or the book really deserves disk space, you should still find out. You should not comment on file dumps, because the name speaks for itself.
')
Actually, my solution is a script that automatically clears these directories, but intelligently, and not immediately. I want to make a reservation that everything on my disk is sorted and located in my directories: “Music”, “Photo”, “Video”, “Books”, “Work”, etc., this is the information I have selected that I know and remember. . Everything that gets there, I listen and watch. The idea is that the downloaded information is stored in “Downloads” for 2 weeks after which, if I remember about it (if this really known and expected book / artist usually remembers this), it falls into one of the designated directories, otherwise it is removed into oblivion. I keep 2 weeks for the process of “remembering” myself. These weeks are not counted for the “Downloads” directory as a whole, but for each file separately, i.e. The script does not delete everything every 2 weeks, and every four hours it checks whether there are no obsolete files that can be deleted. Also, the atime argument is used in the script (by the time of the last file access), if there is, for example, a clip / photo / music for which I am still thinking, the counter counting those same 2 weeks will be reset every time the file is opened. if the information is important and relevant, it will last until I really forget about it. This system has been successfully operating for half a year, one day, after all, several books were deleted that did not manage to move to a smartphone, otherwise there are only pluses.
Actually the scripts themselves:
cat / var / scripts / cleaning
#!/bin/bash
FOLDERS="/mnt/drive_2/shared_folder /mnt/drive_2/Downloads /home/*/Desktop /home/*/Downloads /home/*/.Trash /home/*/.local/share/Trash"
LOGDIR=/var/log/cleaning
LOG="$LOGDIR/log"
# , ,
if [ -d "$LOGDIR" ]; then
echo "directory $LOGDIR is exist"
else
mkdir $LOGDIR
echo "directory $LOGDIR was created"
fi
#
for DIRECTORY in $FOLDERS ; do
echo "PROCESSING_DIRECTORY=$DIRECTORY"
# , 2
find $DIRECTORY -atime +14 -type f | while read FILE ; do
rm -rf "$FILE"
echo "$(date +%d.%m.%y%t%H:%M:%S) File $FILE was delited from $DIRECTORY as old"
echo "$(date +%d.%m.%y%t%H:%M:%S) File $FILE was deleted from $DIRECTORY as old" >> $LOG
done
#
find $DIRECTORY -type d -empty | while read DIR ; do
rm -rf "$DIR"
echo "$(date +%d.%m.%y%t%H:%M:%S) Directory $DIR was delited from $DIRECTORY directory as empty"
echo "$(date +%d.%m.%y%t%H:%M:%S) Directory $DIR was deleted from $DIRECTORY directory as empty" >> $LOG
done
done
exit 0
cat /etc/crontab
# cleaning
45 */4 * * * root /var/scripts/cleaning # cleaning every 4 hours
cat /etc/logrotate.d/cleaning
/var/log/cleaning/log {
rotate 12
monthly
compress
missingok
notifempty
}
, , , :
: find $DIRECTORY -atime +7 -type f -delete
: find $DIRECTORY -type d -empty -delete
, , ( shared ), ( ntp ), , , , , «» , , , .
man find:
-mtime — .
-atime — .
-ctime — .
-mmin — .
-amin — .
-cmin — .
man
find, …