I am running some scripts and they are faulty terrible scripts, So they make the computer run slow. I wanted to restart the OS X computer every night to just refresh what they did. I was having troubles with this and finally just sat down and troubleshooted it.
sudo crontab -e
In Crontab, And enter this and change the time to when you want to restart OS X:
10 0 * * * /sbin/shutdown -r now
The above code will restart the computer at 00:10 every day (morning)
Hopefully this will help others as it has helped me.Â