Added some code for the crontjob. Needs improvement and some error handling