File & Disk Macros

The macros in the sample file_disk_macros.cfg configuration file below are for file and disk management.  You would use these for special file and disk management, for example to clear directories, move or delete core files, clear user disks, show disk usage, etc.

///////////////////////////////////////////////////////////////////////////////
//
// file & disk management macros
//
///////////////////////////////////////////////////////////////////////////////

cleartmp(D, T)
                =find (D) -mtime +(T) -exec =rm {} \; 2>/dev/null
 
///////////////////////////////////////////////////////////////////////////////

clearwebcache(D, T)
                =find (D) -type f -name cache[0-9]\* -mtime +(T) -print |
                =grep '\.netscape' | =xargs =rm 2>/dev/null
 
///////////////////////////////////////////////////////////////////////////////

rmcorefiles(D)
                =find (D) -type f -name core -exec =rm {} \; 2>/dev/null
 
///////////////////////////////////////////////////////////////////////////////

mvrootcore(D)
                if -e "/core"
                        output mail $command("=file /core 2>/dev/null")
                        output mail $command("=ll /core")
                        =execwait "=mv /core (D)"
                        output mail "moved /core file to (D), after the move:"
                        output mail $command("=dfl / | =behead(1)")
                endif
 
///////////////////////////////////////////////////////////////////////////////

clearuserdisk(D, T)
                =clearwebcache((D), (T)); =rmcorefiles((D))
 
///////////////////////////////////////////////////////////////////////////////

dutop(N, D)     // using du, show the top N files/subdirs in directory D
                // (N) is the number of displayed files/subdirs (e.g., 10)
                // (D) is the directory (e.g., /tmp); don't enclose with quotes
                output mail =newline
                if "(D)" eq "/"
                        do #popen(DU, "=dusk /\* | =sort +0nr |
                                       =head -(N)", "r")
                else
                        do #popen(DU, "=dusk (D)/\* | =sort +0nr |
                                       =head -(N)", "r")
                endif
                while #read(DU) > 0
                        output mail $readline
                endwhile
                do #pclose(DU)
                output mail =newline
 

For more examples, see Samples.

 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2019-01-12.   This site is PIKT® powered.
Copyright © 1998-2019 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View sample
file &
disk management
macros