On Tue, Aug 20, 2002 at 11:28:34AM -0700, Desmond Lee wrote: > First off, to automate a process i have to set it up in the /etc/crontab > correct?
That's correct. > Also, what do i do if i want the info to be sent to someone other that root > when the virus scan and back up run? man is your friend. man 5 crontab says: "...cron(8) will look at MAILTO if it has any reason to send mail as a result of running commands in ``this'' crontab. If MAILTO is defined (and non-empty), mail is sent to the user so named. If MAILTO is defined but empty (MAILTO=""), no mail will be sent. Otherwise mail is sent to the owner of the crontab." So, all you need to do is to set the MAILTO variable in your crontab. > THis is what i've added in my /etc/crontab file: > > 00 2 * * sun sweep /www/servers/skylight.ubc.ca/media/ > /www/servers/skylight.ubc.ca/profsTalk > > /www/logs/skylight.ubc.ca/virusLog/log > > 00 1 * * sun /root/scripts/backup.sh Hmm... I think that the first three lines in your crontab should be just one (or did mutt mangle the single long line?). > Okay, so i'm pretty sure that the above is correct. However, when i pipe out > the results of the virus scan to a log file, i want to use the date as the > name of the log file. IS there any way that i can do this? When I've needed to do this, I write a script that runs my process with the output redirected to the log file, and generate the logfile name in the script's code. > Second, the cron tab will run the backup.sh script file. I've just started > to write this script file but i'll a little unsure of what to do. I'm just > writing this out as psuedo code, this is what i've got so far: Just a suggestion: don't put the script in your crontab until it's finnished. It might be run when you did not intend it to and damage your system. > # > # Back up shell script > # > > #!/usr/bin/bash > > $currDate = getDate; Try using the date command in backticks like this: currDate = `date -I` Check man date for fancier formats of the date string. > mkdir /data/backups/$currDate > > # Backup the web server files > tar cfv www.tar /data/www > gzip www.tar > mv www.tar /data/backups/$currDate/ If you want compressed tarballs, either use the -z option in tar, or tar to stdout and pipe into gzip. That will save you some disk space, quite a lot, in fact, if you are backing up a large data set. There is also no reason to backup in one place and then move over to another. Also note that if you stick to backup-then-move, at the move stage, the backup is called www.tar.gz. Try this: (cd /data/www; tar cvzf /data/backups/$currDate/www.tar.gz .) > > # Backup the database > mysqldump --all-databases -udlee -psomepassword > /data/backups/$currDate/ Missing a filename for the mysql backup? > What i'm trying to do is make a directory with the currrent date in teh > existing directory /data/backups. Is ther eany way that i can get this date > and use i in a variable? Above i just put in "getDate" for filler. See comments above. > Also, I think i have to be root to run the above commands, should this be a > problem, or does the crontab run the backup.sh script as root? Not a problem if you place the script in root's crontab. Cheers, -- Javier Gostling Ingeniero de Sistemas Virtualia S.A. [EMAIL PROTECTED] Fono: +56 (2) 202-6264 x 130 Fax: +56 (2) 342-8763 Av. Kennedy 5757, of 1502 Las Condes Santiago Chile
msg86233/pgp00000.pgp
Description: PGP signature