move pidfile and background to separate tasks