in reply to daemonizing my code
In what way did it fail? Are you getting any error messages? Have you read How (Not) To Ask A Question?
Offhand, random things I can think of: