Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ant <delete> task not working

Status
Not open for further replies.

cpjust

Programmer
Sep 23, 2003
2,132
US
Hi,
I can't figure out why this target isn't working.
Code:
	<target name="clear.oldcorefiles.nightly">
		<!-- Determine the earliest timestamp for removal as an offset from the
			 current date and time -->
		<property name="clear.timestamp.pattern" value="MM/dd/yyyy" />
		<tstamp>
			<format
				property="oldcorefiles.timestamp"
				pattern="${clear.timestamp.pattern}"
				unit="day" offset="-14" />
		</tstamp>

		<!-- Delete old files -->
		<delete includeemptydirs="true">
			<fileset dir="/var/corefiles" includes="**/core.*">
				<date
					datetime="${oldcorefiles.timestamp}" when="before"
					pattern="${clear.timestamp.pattern}" checkdirs="true"
				/>
			</fileset>
		</delete>
	</target>
It's giving this error, even though I've made all the core files owned by the user that the ant process is running as and I even made them 'chmod 777'...

Code:
/tmp/cleanup.xml:142: Unable to delete file /var/corefiles/core.15.days
	at org.apache.tools.ant.taskdefs.Delete.handle(Delete.java:624)
	at org.apache.tools.ant.taskdefs.Delete.execute(Delete.java:602)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
	at org.apache.tools.ant.Task.perform(Task.java:348)
	at org.apache.tools.ant.Target.execute(Target.java:357)
	at org.apache.tools.ant.Target.performTasks(Target.java:385)
	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
	at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
	at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
	at org.apache.tools.ant.Main.runBuild(Main.java:758)
	at org.apache.tools.ant.Main.startAnt(Main.java:217)
	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
 
Doh! Nevermind.
Even though the files were writable, it's the directory they're in that needs write permission to delete the files.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top