Daily
These crontab entries use an the find command to removed files that are old and, hopefully, useless.
The first entry checks the whole system for files named core which have not been accessed in the last seven days and removes them.0 1 * * * find / -atime +7 -name core -exec rm -f {} \; 25 5 * * * find /usr/spool/printer/. -name '?f*' -type f -mtime +1 -exec rm -f {} \; 15 1 * * * find /tmp -atime +7 -exec rm -f {} \; 19 1 * * * find /var/tmp -atime +7 -exec rm -f {} \;
These crontab entries mail the output of the commands df and du to the root account so that they can be reviewed. In this way, the system administrator may monitor the amount of disk space available on all the filesystems and trace the users who have more than their fair share of disk space.
0 20 * * * df -ks | /usr/ucb/mail -s "Filesystem usage" root > /dev/null 2>&1 0 8 * * * du -ks /home/\* | sort -nr | head | /usr/ucb/mail -s "/home usage" root > /dev/null 2>&1
Weekly
This crontab entry uses the command fsck with the no write option to provide a status checking of all the mountable file systems while the system is in multi-user mode. The check is performed at two minutes after midnight on Monday. The output of the command will have some errors concerning the superblock, because the file system is currently mounted, however a long list of errors could mean impending disk failure.0 2 * * 1 fsck -n | /usr/ucb/mail -s "Filesystem check" root > /dev/null 2>&1
Monthly
This cron table entry executes the script /var/adm/monthly once at 5 minutes after one the first of each month. This allows all the monthly tasks to be executed from one script instead of having one entry for each task.
Add to the script all the things that should be done at the first of the month.5 0 1 * * /var/adm/monthly > /dev/null 2>&1
#!/bin/sh # Filename: /var/adm/monthly # Perform clean up, rollover of files # Solaris 2.x # Create a new lastlog cp -p /var/adm/lastlog /var/adm/lastlog.old cp /dev/null /var/adm/lastlog # Create new wtmp files cp -p /var/adm/wtmp /var/adm/wtmp.old cp -p /var/adm/wtmpx /var/adm/wtmpx.old cp /dev/null /var/adm/wtmp cp /dev/null /var/adm/wtmpx # Run stat software for the ftp server and web server /usr/local/adm/stats
Once a month, on the first of the month, find all files in the /home directory that has not been accessed in 16 days and are greater than 10000 bytes. Mail the results to root for review.
10 0 1 * * find / -type f -xdev -atime +16 -size +10000 -exec ls -lt {} \; / | /usr/ucb/mail -s "Large files report" root > /dev/null 2>&1