On Mon, Dec 4, 2017 at 8:34 AM, Jousma, David <[email protected]> wrote:
> Speaking of skulker, I have implemented its use via cron to keep /tmp
> cleaned up. There are a few files that get written there by some life of
> IPL started tasks(mostly TCPIP related) that do exceed the time frame
> skulker is cleaning up, so I created another script that runs prior to
> skulker that simply does a touch -c to update the date/time stamp of the
> file if it already exists for a list of "loved files". I didn’t initially
> create this script as most of the tasks didn’t complain, until we
> implemented the IOBSNMP extension of SNMP and it writes a dip_socket file
> there, that if deleted, causes problems for it.
>
Another possibility you might consider, instead of having a hard coded
list of "loved ones", is to use the fuser (file user) command. This command
can be used to list all of the files which are "open" in a given directory.
Something like:
find /tmp/ ! -type d -atime +3 -exec fuser {} \; 2>&1 | awk 'NF == 1' |
sed -E 's/: *$//' | xargs rm -v
This runs the find command. For each non-directory file (! -type d) which
is over 3 days old, execute the fuser command on it. fuser, for some
reason, writes its data to stderr instead of stdout. So I redirect stderr
to stdout (2>&1). I then pipe the output of fuser into "awk". If fuser
finds any users for a file, it writes out the PID for that user after the
file name (e.g. /tmp/somefile: 201327 273979c). The awk step removes any
output from fuser which has a PID after it (i.e. there is only one field
output; NF is "Number of Fields" in awk). The "sed" command removes
trailing blanks and the semi-colon. It then feeds this into xargs which
runs the "rm" command on all the files output. You could even remove the
"-atime +3" which is only there to try to avoid removing open files.
Just a thought. And no, I don't do the above because I just now thought of
it.
>
> _________________________________________________________________
> Dave Jousma
> Manager Mainframe Engineering, Assistant Vice President
> [email protected]
> 1830 East Paris, Grand Rapids, MI 49546 MD RSCB2H
> p 616.653.8429
> f 616.653.2717
>
Maranatha! <><
John McKown
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN