Make the script work inside a cron job