PID files

Hi folks

This isn’t strictly an Apple Script question, but depending on the answer, I might be doing what I’m doing wrong anyway so I figured I’d ask here.

I have an Apple Script application that is split into a few different scripts (one to handle incoming requests, one to process them in order etc.), and to make sure requests don’t “collide”, I write a PID file on start and delete it at the end, so I can check if there’s a PID file for my application and decide to wait or to start.

My problem:
I write my PID files to /private/var/run/ (that’s where they should be, right?) and because the user running these scripts isn’t root, he doesn’t have permission to write there. So I created a sub folder at that location and chown’d it to the right user. This works fine, except every time I reboot my mac, that folder gets deleted. I tried putting a .keep file in it, but that was no help.

Is this a privilege issue or should I be doing this completely different?


  • Chris

Model: MacBook Pro
AppleScript: 2.0.1
Operating System: Mac OS X (10.5)

Hi phore,

I use a similar approach for some of my work projects, but I am storing the lock files in the Application Support folder.

Or do you absolutely need a place which is accessible from each user?

Best regards,


Hi Martin

No, it actually doesn’t need to be available for everyone. Sounds good to me, I thought the /private/var/run/ way was the way to go since other tasks write their PID files their. I adjusted it and it seems to be working.