Modified to use a temporary file for storing active pids. Better for my sync script