Fixed script generator to be run by cron (outside of dashboard)