Use temp file instead of using PID