A script, at its shortest, is simply a series of commands that your shell understands (as if you typed them in yourself). To shut down your computer (from a terminal) you'd use something like
shutdown,
A bash script, for example, could be simply
Code:
#!/bin/bash
shutdown
and after
you could run it (provided that the file was called script.sh and that shutdown was in a directory that was included in $PATH environment variable). You should probably put the whole path to shutdown into the script, to be sure. The first row in the script tells which interpreter should be used to run the script, in this case bash (there are lots of other options here, depending on how you want to do things, bash is just one way). Or, you could just put the word "shutdown" in the file (call it, say, "scriptfile") and run
and you'd very probably get the same result--here you'd explicitly make "sh" (which might actually be "bash") run the contents (or "script") of the given file. You wouldn't even have to make it executable using "chmod" if you did it this way. This way you can just add programs to be run into the script, like your backup program (whatever it is), and run the script. Or you could run it through cron for example, to make it all happen at some pre-specified time (just add the script to crontab, and make sure that you specify all executables with full path, to make sure everything works).
That's the basics. There are loads of tutorials out there about scripting on a variety of languages, so keep reading if you just got interested. After you get past the plain ol' running commands state, you'll soon learn you can do a bunch of things. Actually, your whole backup program can very well be "simply" a script, even though it did wonders. And yes, at some point you do want to know how to run your scripts at startup (init scripts) or at a given time (cron/anacron) or at shutdown or at the end of the day or at tea time or whenever you didn't know you wanted them to run..so get used to crons and such
The first problems you'll probably face when timing the running of your scripts, i.e. not running them yourself directly, are "program not found"s or equivalents, which are caused by you not telling exactly what to run and where from. As long as you work in your nice comfortable personal shell with a fancy environment defined, all works well, but you can't rely on all those environment variables etc. being set all the time (such as $HOME or $PATH -- try to echo them to see what they contain!).