Запретить systemd очистить мой / tmp

Если у вас оболочка bash версии 4:

declare -i total=0
declare -A type
if [ -s "$1" ]; then
    while IFS=, read name id job; do
        [[ $job =~ ^[[:space:]]*(.+)[[:space:]]*$ ]] &&
        (( type["${BASH_REMATCH[1]}"]++, total++ ))
    done < "$1"
    for job in "${!type[@]}"; do
        printf "There are %d '%s' employees.\n" ${type["$job"]} "$job"
    done
    echo "There are a total of $total employees in the company"
else
    echo "ERROR: file '$1' does not exist or has zero size."
fi

Или используйте awk:

awk -F' *, *' '
    { type[$3]++; total++ } 
    END {
        for (job in type) 
            printf "There are %d '\''%s'\'' employees.\n", type[job], job
        print "There are a total of", total, "employees in the company"
    }
' "$1"
2
24.03.2019, 05:59
1 ответ

поместите это в /etc/rc.local:

# disable the daily cleaning
systemctl disable systemd-tmpfiles-clean.timer
# make sure /tmp is cleaned now (might be superfluous, but what the heck?)
systemctl start systemd-tmpfiles-clean.service

и включите rc.local:

 systemctl start rc-local.service
3
27.01.2020, 22:02

Теги

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