Change to another way to get DIR. Not perfect but hopefully now works with a cronjob