Help with automated file and directory deletion

(imported topic written by ontai91)

I’ve got a web server that runs about eight JVMs. If a certain log file gets too large, the middleware server starts producing 1 GB log files every minute. The vendor had told us to restart the JVMs each night and we implemented the restart successfully through a custom action.

Now the vendor says we should check the file size between restarts. I used the fixlet debugger to confirm the relevance expression, but last night the script stopped the JVMs and then didn’t restart them. I’m presuming it got hung up on the deletion portion. We want to delete the entire contents of the log directory

// enter your action script here

wait net stop MarketLive_JVM1

wait net stop MarketLive_JVM2

wait net stop MarketLive_JVM3

if exists file “D:\log\batch_import” and (size of it) of file “D:\log\batch_import” < 102,400,000 then delete “D:\log*”

wait net start MarketLive_JVM1

wait net start MarketLive_JVM2

wait net start MarketLive_JVM3

Any idea why all of the net start statements are failing?

(imported comment written by ontai91)

Sorry, that’s a “>” sign, not a “<” sign for the file size…

(imported comment written by ontai91)

The log file shows the three services stopping successfully and then it finds the relevance expression non-relevant and stops. But it doesn’t continue on and run the net start commands:

At 02:32:01 -0700 - actionsite (http://SF-BigFix1.ontai.net:52311/cgi-bin/bfgather.exe/actionsite)

Command succeeded wait net stop MarketLive_JVM1 (fixlet 1612)

At 02:32:15 -0700 -

Report posted successfully.

At 02:32:15 -0700 - actionsite (http://SF-BigFix1.ontai.net:52311/cgi-bin/bfgather.exe/actionsite)

Command succeeded wait net stop MarketLive_JVM2 (fixlet 1612)

At 02:32:23 -0700 - actionsite (http://SF-BigFix1.ontai.net:52311/cgi-bin/bfgather.exe/actionsite)

Command succeeded wait net stop MarketLive_JVM3 (fixlet 1612)

At 02:32:24 -0700 - actionsite (http://SF-BigFix1.ontai.net:52311/cgi-bin/bfgather.exe/actionsite)

Not Relevant - Wakeside JVM Restart (fixlet:1612)

(imported comment written by BenKus)

Hi ontai,

I am not sure exactly why it didn’t report a failure, but it looks like your syntax for the if statement is not correct… I corrected the syntax and adjusted a few things to try to make it work better…

It should be something like this:

wait net stop MarketLive_JVM1
wait net stop MarketLive_JVM2
wait net stop MarketLive_JVM3
if {(exists file “D:\log\batch_import”) and (size of file “D:\log\batch_import” > 102400000)}
dos del "D:\log*.*"
endif
wait net start MarketLive_JVM1
wait net start MarketLive_JVM2
wait net start MarketLive_JVM3

Ben