$ ! $ ! EMAIL-CUSTODIAN $ ! $ ! The EMAIL CUSTODIAN performs housekeeping on mail files on the system $ ! by performing the following tasks for each user: $ ! $ ! * Removes mail from the NEWMAIL (INBOX) folder older than 90 days. $ ! * Removes mail from the MAIL folder older than 90 days. $ ! * Deletes all mail from the "deadletter" and "Trash" folders. $ ! * Empties the WASTEBASKET folder (using PURGE/RECLAIM) $ ! * Compresses the MAIL.MAI file $ ! $ ! It also resubmits itself to run at 2:00am the following Saturday. $ ! $ begin: $ version = "V1.1" $ proc = f$environment("procedure") $ procname = f$parse(proc,,,"name","syntax_only") $ write sys$output "''procname' ''version'" $ $ resubmit: $ procedure = proc - f$parse(proc,,,"version","syntax_only") $ weekday = f$cvtime(f$time(),"absolute","weekday") $ if (weekday .eqs. "Saturday") then add = 7 $ if (weekday .eqs. "Sunday") then add = 6 $ if (weekday .eqs. "Monday") then add = 5 $ if (weekday .eqs. "Tuesday") then add = 4 $ if (weekday .eqs. "Wednesday") then add = 3 $ if (weekday .eqs. "Thursday") then add = 2 $ if (weekday .eqs. "Friday") then add = 1 $ submit/user=system/noprinter/queue=sys$batch - 'procedure'/after="today+''add'-02:00" $ if (f$environment("INTERACTIVE")) then exit $ $ setup: $ set proc/priv=all $ ! Set up a list of disk logicals $ device_names = "diska,diskb,diskc,diskd,diske,diskf,diskg,diskh," - + "diski,diskj,diskk,diskl,diskm,diskn,disko,diskp," - + "diskq,diskr,disks,diskt,disku,diskv,diskw,diskx," - + "disky,diskz" $ device_element = 0 $ $ device_loop: $ device = f$element(device_element,",",device_names) $ if (device .eqs. ",") then goto finish $ device = device - ":" + ":" ! make sure a colon is at the end $ device_element = device_element + 1 $ $ loop: $ mailfile = f$search(device+"[*...]mail.mai") $ if (mailfile .eqs. "") then goto device_loop $ username = f$parse(mailfile,,,"directory") - "[" - "]" - "<" - ">" $ username = f$element(0,".",username + ".") $ type_ver = f$parse(mailfile,,,"type") + f$parse(mailfile,,,"version") $ mailfile = mailfile - type_ver $ oldfile = mailfile + ".OLD" ! Old Mail file name $ mailfile = mailfile + ".MAI" ! Mail file name $ $ dowork: $ write sys$output "--------------------------------------------------" $ context = "" $ setup = f$context ("process", context, "username", username, "eql") $ pid = f$pid(context) $ if (pid .eqs. "") $ then write sys$output "* Processing ''username'..." $ else write sys$output "* User ''username' logged in - skipping..." $ goto loop $ endif $ set noon $ open/write mailproc email-temp.com $ write mailproc "$ EMAIL" $ write mailproc "SET USER ''username'" $ write mailproc "SELECT/BEFORE=-90-0 NEWMAIL" $ write mailproc "DELETE/ALL" $ write mailproc "SELECT/BEFORE=-90-0 MAIL" $ write mailproc "DELETE/ALL" $ write mailproc "SELECT ""deadletter""" $ write mailproc "DELETE/ALL" $ write mailproc "SELECT ""Trash""" $ write mailproc "DELETE/ALL" $ write mailproc "PURGE" $ write mailproc "COMPRESS" $ write mailproc "EXIT" $ write mailproc "$ EXIT" $ close mailproc $ @email-temp.com $ delete/log 'oldfile';* $ delete/nolog email-temp.com; $ set on $ goto loop $ $ finish: $ exit