For part A, you'll want Cron. Tim Hoolihan has a good example of that in his answer.
For part B, you'll want a shell script. To make one, just make a textfile that starts with the following line:
And then follow that with commands like you were typing into the shell. (Advanced tip: the #! syntax works for any command-line program, not just
Once that's done, save it (it's recommended to use a .sh extension, but not at all neccessary), go to your shell and run
chmod ugo+x filename.sh, substituting the actual filename, of course. This will make it so your script can be executed.
Finally, just put the script in the crontab per Tim's answer.
Hope this helps.