Setup cron jobs function

Also adjusted a few variables and fixed an if statement that was
overwriting the schedule variable.