moved background task into main script, moved log location into environment