Write pid file to temp folder