daily

来自「minix操作系统最新版本(3.1.1)的源代码」· 代码 · 共 72 行

TXT
72
字号
#!/bin/sh## daily - daily cleanup of the system.# Doesn't make sense when running from CDif [ -f /CD ]then	exitficase "$#:$1" in1:cron|1:boot)    caller=$1    ;;*)  echo >&2 "Usage: $0 cron|boot"    exit 1esactest -d /usr/adm || exitcd /usr/adm || exit# Last run must have been on a previous day.timestamp=daily.lasttimeif test -f $timestampthen    set -- `ls -lT $timestamp`    test "$6 $7 $9" = "$(date '+%b %d %Y')" && exitfi>$timestamp# Remove three day old files from various tmp dirs.cleantmp -3 /tmp /usr/tmp /usr/preserve /usr/spool/lpd /usr/spool/at/past# Truncate log files in /usr/adm.test -d old || mkdir old || exitcycle(){    # Cycle a log file if larger than a size in kilobytes.    local size="`expr "$1" + "$1"`"    local log="$2"    if test -f "$log" && test -n "$(find "$log" -size +"$size")"    then	test -f "old/$log.2" && cp -p "old/$log.2" "old/$log.3"	test -f "old/$log.1" && cp -p "old/$log.1" "old/$log.2"	cp -p "$log" "old/$log.1"	: > "$log"    fi}cycle 100 wtmp cycle 100 log cycle  20 ftplogcycle 200 aftplog# Make copies of /etc/passwd and /etc/shadow if they have been changed.for file in passwd shadowdo    if cmp -s /etc/$file old/$file.1    then	# Fine.    else	test -f old/$file.2 && cp -p old/$file.2 old/$file.3	test -f old/$file.1 && cp -p old/$file.1 old/$file.2	test -f /etc/$file && cp -p /etc/$file old/$file.1    fidone# Continue with a local script if present.test -f /usr/local/etc/daily && sh /usr/local/etc/daily $callerexit 0

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?