skulker [–iw][–r|–R] [–l logfile ] directory days_old
skulker finds files that are candidates for deletion in directory, based on comparing the file's access time to the age specified by days_old.
find directory -type f -atime +days_old -level 0 ! -name "*'*" ! -name "*
*" -print
The preceding find command
has a deliberate newline inserted as part of the second -name request.For example, specifying 5 for days_old causes the find command to find files that are equal to or older than five 24-hour intervals earlier than now.
Restriction: This script ignores path names that contain single quotes or newlines when determining the list of objects that are candidates for deletion.
The skulker script (which is a z/OS shell script in /samples) should be copied and can be modified to suit your particular needs. Possible locations for placing the script include /bin or /usr/sbin, especially if skulker is to be run from a UID(0) program. If skulker is to be run by users, /usr/bin is another possibility, but check that the sticky bit is on in the directory. If the script is called from a privileged user (a superuser, a user with a UID of 0, or a user running with the RACF® trusted or privileged attribute), it is important to protect the script from any modifications by a non-privileged user.
The code page in which a shell script is encoded must match the code page of the locale in which it is run. For a shell script to be shared by multiple users, they must all be in a locale that uses the same code page as the code page in which the shell script is encoded. If you have different users operating in various locales, you need multiple copies of the skulker shell script, one for each different locale code page. You can use the iconv command to convert the skulker shell script from one code page to another.
find directory -atime +days_old ! -type d ! -name "*'*" ! -name "*
*" -print
The find command in
the preceding example has a deliberate newline inserted as part of
the second -name request. The -r option is mutually exclusive with the -R option.
find directory -atime +days_old ! -name directory ! -name "*'*" ! -name "*
*" -print
The ! -name directory
primary prevents skulker from deleting the
actual directory that was entered as a start point (for example, /tmp).The find command in the preceding example has a deliberate newline inserted as part of the third -name request.
The -R option is mutually exclusive with the -r option.
By default, files are removed from the specified directory based on access time and their status as regular files, and are removed only from the directory specified (not from any subdirectories).
skulker /tmp/ 100
The
trailing slash in /tmp/ is necessary if /tmp is a symbolic
link and you want to list or remove files from the directory the link
points to, rather than the symbolic link itself. If /tmp (or
the directory specified) is not a symbolic link, the trailing slash
has no effect. > ls -lL /tmp
total 48
-rw------- 1 BILLYJC SHUT 0 Nov 10 06:00 10.txt
-rw------- 1 BILLYJC SHUT 0 Nov 11 06:00 11.txt
-rw------- 1 BILLYJC SHUT 0 Nov 12 06:00 12.txt
-rw------- 1 BILLYJC SHUT 0 Nov 13 06:00 13.txt
-rw------- 1 BILLYJC SHUT 0 Nov 14 06:00 14.txt
-rw------- 1 SUPERID SHUT 0 Nov 15 06:00 15.txt
-rw------- 1 BILLYJC SHUT 0 Nov 16 06:00 16.txt
-rw------- 1 BILLYJC SHUT 0 Nov 17 06:00 17.txt
-rw------- 1 BILLYJC SHUT 0 Nov 18 06:00 18.txt
-rw------- 1 BILLYJC SHUT 0 Nov 19 06:00 19.txt
> date
Mon Nov 29 11:17:20 EST 1999
> skulker -i /tmp/ 11
-rw------- 1 BILLYJC SHUT 0 Nov 10 06:00 10.txt
-rw------- 1 BILLYJC SHUT 0 Nov 11 06:00 11.txt
-rw------- 1 BILLYJC SHUT 0 Nov 12 06:00 12.txt
-rw------- 1 BILLYJC SHUT 0 Nov 13 06:00 13.txt
-rw------- 1 BILLYJC SHUT 0 Nov 14 06:00 14.txt
-rw------- 1 SUPERID SHUT 0 Nov 15 06:00 15.txt
-rw------- 1 BILLYJC SHUT 0 Nov 16 06:00 16.txt
-rw------- 1 BILLYJC SHUT 0 Nov 17 06:00 17.txt
-rw------- 1 BILLYJC SHUT 0 Nov 18 06:00 18.txt
Do you really want to delete these files? If yes, answer [y|Y].
Any other response cancels your request.
y
Deleting files...
> ls -lL /tmp
total 48
-rw------- 1 SUPERID SHUT 0 Nov 15 06:00 15.txt
-rw------- 1 BILLYJC SHUT 0 Nov 19 06:00 19.txt
>
Note that non-superuser BILLYJC (who issued the skulker command)
was not able to delete the superuser's (SUPERID) file (15.txt),
even though the find command issued from skulker returned 15.txt as
a file name to delete. > crontab
15 3 * * 1-5 /etc/skulker -l /usr/spool/cron/skulker.log /tmp/ 100
<control-D>
>
This
example removes all regular files from /tmp that were last
accessed 100 or more days ago. By default, cron sends
the stdout and stderr of the command in a mail message to the user
who submitted the cron job.skulker -R /tmp/ 30
-mtime +days_old
to
the find requests within skulker.
To include the change time, add the primary -ctime +days_old
to
the find requests within skulker.