#!/bin/sh # /etc/cron.daily/standard: standard daily maintenance script # Start in the root filesystem cd / LOCKFILE='/var/lock/cron.daily' umask 022 # Avoid running more than one at a time if [ -x /usr/bin/lockfile-create ] then lockfile-create $LOCKFILE if [ $? -ne 0 ] then cat </dev/null | awk '/\/dev\// { print }' | sed -e 's/ [[:space:]]*/ /g' | while read mount block used avail perc mp do [ "$mp" = "/" ] && mp="" echo "$mp/lost+found" done | while read lfdir do # In each directory, look for files if [ -d "$lfdir" ] then more_lost_found=`ls -1 "$lfdir" | grep -v 'lost+found$' | sed 's/^/ /'` if [ -n "$more_lost_found" ] then lost_found="$lost_found $lfdir: $more_lost_found" # NOTE: above weird line breaks in string are intentional! fi else no_lost_found="$no_lost_found $lfdir" fi done # NOTE: This might need to be configurable if systems abound # w/o lost+found out there to prevent giving out this warning # every day. if [ -n "$lost_found" ] then cat << EOF Files were found in lost+found directories. This is probably the result of a crash or bad shutdown, or possibly of a disk problem. These files may contain important information. You should examine them, and move them out of lost+found or delete them if they are not important. The following files were found: $lost_found EOF fi if [ -n "$no_lost_found" ] then cat << EOF Some local filesystems do not have lost+found directories. This means that these filesystems will not be able to recover lost files when the filesystem is checked after a crash. Consider creating a lost+found directory with mklost+found(8). The following lost+found directories were not available: $no_lost_found EOF fi # Clean up lockfile if [ -x /usr/bin/lockfile-create ] then kill $LOCKTOUCHPID lockfile-remove $LOCKFILE fi