Очистка кеша миниатюр с терминала в Ubuntu 14.04

Я хочу освободить место, очистив кэш миниатюр от терминала.

Внутри папки ~/.cache/thumbnails я вижу 3 папки:

  1. сбой
  2. большой
  3. нормальный

Безопасно ли убирать все три папки?

5
задан 2 June 2015 в 09:15

3 ответа

В миниатюрах Ubuntu 14.04 хранятся в ~/.cache/thumbnails, в то время как в Ubuntu 12.04 хранится в ~/.thumbnails.

Просто можно удалить все там включая те каталоги, не будучи боящимися чего-то, плохо произойдет. Это просто сбросит Ваши миниатюры, заставляя их быть воссозданным согласно глобальным настройкам.

0
ответ дан 2 June 2015 в 09:15

Вы могли запланировать удаление Ваших файлов миниатюры путем редактирования Вашего crontab с командой crontab -e и добавления строки такой как 30 09 * * * find /home/yourname/.cache/thumbnails/ -maxdepth 3 -type f -delete, как предложено "troller" здесь .

0
ответ дан 2 June 2015 в 19:15
  • 1
    Проблема, являющаяся с Создателем Загрузочного диска, вероятно, маловероятна. Поскольку, как я записал, это хорошо работает с Ubuntu 14.04. – user255726 1 September 2016 в 18:50

Немного сценария командной строки, затем!

#!/bin/bash
# Checked with https://www.shellcheck.net/

set -o nounset

user=             # user to clean
do_it=            # nonempty to actually run remove commands
cmdline_user=     # user given on cmdline (if any)

# ---
# Option processing
# ---

processOptions() {

   # We use bash regular expressions, which are "grep" regular expressions; see "man grep"
   # or "man 7 regex"
   # In that case, the string on the right MUST NOT be enclosed in single or double quotes,
   # otherwise it becomes a literal string

   local param=       # Current parameter
   local use_user=    # Set to nonempty if a user argument is expected in the next PARAM

   local unknown=     # Accumulates unknown PARAMS
   local print_help=  # Set to nonempty if help requested

   for param in "$@"; do   

      # Process arguments that are separate from their option

      if [[ -n $use_user ]]; then
         cmdline_user=$param
         use_user=""
         continue
      fi

      # Process option

      if [[ $param == '--do' ]]; then
         # set global variable
         do_it=YES
         continue
      fi

      if [[ $param =~ --user(=.+)? ]]; then
         if [[ $param =~ --user=(.+)? ]]; then
            # set global variable
            cmdline_user=$(echo "$param" | cut --delimiter="=" --fields=2)
         else 
            # expecting value
            use_user=1
         fi
         continue
      fi

      if [[ $param == '--help' || $param == '-h' ]]; then
         print_help=1
         break
      fi

      # if we are here, we encountered something unknown in PARAM
      # if UNKNOWN is already set, add a comma for separation

      if [[ -n $unknown ]]; then
         unknown="$unknown,"
      fi

      unknown="${unknown}${param}"

   done

   if [[ -n $unknown ]]; then
      echo "Unknown parameters '$unknown'" >&2
      print_help=1
   fi

   if [[ -n $print_help ]]; then
      echo "--user=... to explicitly give user to clean" >&2
      echo "--do       to actually perform operations instead of just printing them" >&2
      exit 1
   fi

}

processOptions "$@"

# The user to handle is either myself or it comes from the command line

if [[ -n $cmdline_user ]]; then
   user=$cmdline_user
else
   user=$(whoami)
fi

# Does the user actually exist? If so get the home dir 

if ! record=$(getent passwd "$user"); then
   echo "Could not get passwd entry of user '$user' -- exiting" >&2
   exit 1
fi

zehome=$(echo "$record" | cut -f6 -d:)

if [[ ! -d "$zehome" ]]; then
   echo "Home directory of user '$user' is '$zehome' but that directory does not exist -- exiting" >&2
   exit 1
fi

# ********
# Path to actually clean out, configure as needed
# ********

clean[0]="$zehome/.cache/thumbnails"
clean[1]="$zehome/.kde/share/apps/okular/docdata"

# Run operations. Depending on "do_it", it's done or not!

for dir in "${clean[@]}"; do   
   if [[ ! -d "$dir" ]]; then
      echo "(Directory '$dir' does not exist or may not be a directory -- skipping that directory)" >&2
   else
      if [[ -z $do_it ]]; then
         echo "Would run: /bin/rm -r \"$dir\""
      else
         echo "Running: /bin/rm -r \"$dir\""
         /bin/rm -r "$dir"
      fi
   fi
done
0
ответ дан 23 November 2019 в 09:06

Другие вопросы по тегам:

Похожие вопросы: