What is a neat way to delete a stale amavisd pid_file on first boot after panic or power failure?
Create a launchd item that runs on boot (system startup before amavisd is started) executing the command to test that /private/var/run/amavisd.pid exists and then delete it:

if test -f /private/var/run/amavisd.pid; then rm /private/var/run/amavisd.pid




&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC -//Apple Computer//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;amavisd_delete_pid&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;if&lt;/string&gt;
        &lt;string&gt;test&lt;/string&gt;
        &lt;string&gt;-f&lt;/string&gt;
        &lt;string&gt;/private/var/run/amavisd.pid;&lt;/string&gt;
        &lt;string&gt;then&lt;/string&gt;
        &lt;string&gt;rm&lt;/string&gt;
        &lt;string&gt;/private/var/run/amavisd.pid&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;Nice&lt;/key&gt;
    &lt;integer&gt;10&lt;/integer&gt;
    &lt;key&gt;KeepAlive&lt;/key&gt;
    &lt;false/&gt;
    &lt;key&gt;AbandonProcessGroup&lt;/key&gt;
    &lt;true/&gt;
&lt;/dict&gt;
&lt;/plist&gt;