There is a lot of control you can have here, but the basic thing that you want is for the root to run a system backup in the middle of the night. This is how you do that. For more, read the cron and crontab man pages. For once, I think these man pages were actually written by English speaking humans. What a nice treat.
if you saycrontab -eit will dump you into your favorite editor and let you enter cron information. When you quit the editor, your cron data is added to the crontabs. You specify your favorite editor by setting your EDITOR environment variable. Depending on what shell you are running, this might be done bysetenv EDITOR viorsetenv EDITOR=viIn this case my EDITOR was set to vi. You may like joe, or pico or emacs. For simple things like this, I prefer vi (although emacs does rule in general). To check you editor setting simply type env and it will spit out all of your environment variables.Then, as root, you can
crontab -eIn your favorite editor enter your crontab information. In the basic case you want six tab separated fields.1 2 3 4 5 61 - enter the minute (0-59) of the time when this should start
2 - enter the hour (0-23) of the time when this should start
3 - enter the day (1-31) of the month when this should start
4 - enter the month (1-12) of the year when this should start
5 - enter the day (0-6 w/ 0=Sunday) of the week when this should start
6 - enter the command which should run at this date/time.
You can enter * to indicate any of the values, for example
0 2 * * * /etc/backupwill run the program /etc/backup at 2:00 am every day of the week and month.You should remember that your /etc/backup program (or whatever you name it) will run as root (if thats who made the crontab entry) and may not have the PATH and other environment variables that a normal user has. To be safe my backup uses the t-shell #!/bin/tcsh is the first line of my backup and I set whatever environement variables I need to start out with. The I give full path names for everything including commands like tar, cp, mv This level of analness is not required, but if your script seems to run at the designated time, but doesn't work, this may be a reason why.
Thats about it. Quit the editor and you're done.
To verify try
crontab -l
Return to Gene's Home Page
Return to Gene's Random Unix Crap