Fix the broken LD_LIBRARY path in cron and move the elements into one common function