How to delete directory content with launchd I am trying to empty a directory at the end of the day, so I have written the following script:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;com.my.script.removetemp&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;rm&lt;/string&gt;
        &lt;string&gt;-fr&lt;/string&gt;
        &lt;string&gt;/tmp/test/*&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;StartCalendarInterval&lt;/key&gt;
    &lt;dict&gt;
        &lt;key&gt;Minute&lt;/key&gt;
        &lt;integer&gt;45&lt;/integer&gt;
        &lt;key&gt;Hour&lt;/key&gt;
        &lt;integer&gt;23&lt;/integer&gt;
    &lt;/dict&gt;
&lt;/dict&gt;
&lt;/plist&gt;


I named it com.my.script.removetemp.plist and placed it in ~/Library/LaunchAgents/, but it doesn’t work.

What am I doing wrong?
Shell globbing (&lt;string&gt;/tmp/test/*&lt;/string&gt;) is not supported by launchd!

You can either remove the whole folder test &lt;string&gt;/tmp/test&lt;/string&gt; or launch a shell script rmtestcontent (in the example /usr/local/bin/rmtestcontent) with the content: 

#!/bin/bash

/bin/rm -fr /tmp/test/*


with the plist:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;com.my.script.removetemp&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;/bin/sh&lt;/string&gt;
        &lt;string&gt;-c&lt;/string&gt;
        &lt;string&gt;/usr/local/bin/rmtestcontent&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;StartCalendarInterval&lt;/key&gt;
    &lt;dict&gt;
        &lt;key&gt;Minute&lt;/key&gt;
        &lt;integer&gt;45&lt;/integer&gt;
        &lt;key&gt;Hour&lt;/key&gt;
        &lt;integer&gt;23&lt;/integer&gt;
    &lt;/dict&gt;
&lt;/dict&gt;
&lt;/plist&gt;


to empty the directory /tmp/test.