Portál AbcLinuxu, 6. května 2025 23:06
tmpfs /var/www/cache tmpfs rw,size=2G,nr_inodes=10k,noexec,nodev,nosuid,mode=1700 0 0
2] automaticke cisteni tohoto adresare, konfigurace v /etc/tmpfiles.d/cache.conf
# always enable /var/www/cache folder cleaning
D! /var/www/cache 1777 root root 0
# remove files older than 5 minutes
D /var/www/cache 1777 root root 5m
3] systemd-tmpfiles-clean.timer byl "override" na 5m cyklus
Tahle kombinace funguje. Ale:
a] soubory se vytvareji s flagem 644, pricemz mam definovano 1700 v 1] ?
b] existuje lepsi reseni nez tahle trojkombinace? Napr. tmp slozka se da udelat pres systemd-tmpfiles unitu, ale ta neumi omezit velikost, na druhou stranu fstab varianta zase neumi nastavit zivotnost.
Řešení dotazu:
#!/bin/bash arch='./Archive' archlast="$arch.last" incoming="./Incoming" cd ~/tmp find -maxdepth 1 -mtime +2 -ctime +2 \ | grep -v -e '^'"$arch"'$' -e '^'"$archlast"'$' -e '^'"$incoming"'$' -e '^./mnt$' -e '^./directory$' \ | while read f do target="$arch/`find "$f" -maxdepth 0 -printf '%CY/%Cm\n'`" mkdir -p "$target" mv -- "$f" "$target" done last=`find "$arch" -mindepth 2 -maxdepth 2 -type d | sort -nr | head -1` [ -L "$archlast" ] && rm -f -- "$archlast" ln -s "$last" "$archlast"Není to dokonalé, ale celkem to funguje. Spouštím to co pár hodin z cronu.
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.