Common code for cron and other scripts (both web and shell)