01-23-2003, 07:53 PM
I have a script that first backups a db and then ftps it to a remote server.
How can I do a test that says if all that worked email me to tell me everything is OK, else tell me something is wrong?
It's a cron job btw.
PS just the commands to email me would be fine, but the conditional stuff is a mystery to me too!
01-23-2003, 08:24 PM
Can't really answer your questions when you don't tell us what language or shell you are using for your scripting. Perl? sh (Bourne Shell)? bash (Bourne Again Shell)? csh (C-Shell)? ksh (Korn Shell)?
01-23-2003, 08:36 PM
bash on redhat 7.2 sorry :o
01-23-2003, 10:00 PM
Hmmm conditional statements in bash are fairly straight forward
As for sending mail you can use the linux mail command. Of course I seem to recall that when you run a cron job a mail gets sent to root regardless unless it was disabled in your scripting. Has anyone checked root's email lately?
01-23-2003, 11:22 PM
Thanks, that test page looks good and should help me with the scripting side of it.
However, I was wondering if you could give me a hand with 'mail'.
for e.g. I want to do a test to see if something's worked and if it has then something like this to happen.
mail ( firstname.lastname@example.org, subject="HEY IT WORKED", body="at so and so time etc." );
Now I know that isn't the syntax, but from the small mail --help it didn't help me work it out how to do that :(
Also, I was wondering how i might do the following (pushing luck here with you guys but I a newbie). Currently I run a backup:-
tar -czf sitebackup23-01-03.tar.gz /home/virtual/site/
I was wondering is there anyway of automatically getting the shell to put in the current date, so I can constantly automatically add to backups without overwriting previous ones?
I promise I'll stop asking newb questions in a bit!!! :)
01-24-2003, 01:22 AM
mail username -s "Subject of Email"
Content of Email
01-24-2003, 01:29 AM
Thank you thank you thank you thank you.
Did I thank you? :)
01-24-2003, 01:40 AM
Well i'd make sure everything works first. lol :)
As far as the backups do you mean put the current date as part of the file name?
01-24-2003, 09:47 AM
Originally posted by Spookster As far as the backups do you mean put the current date as part of the file name? [/B]
Yep. Exactly that.... it would be better than using a static filename which would then get overwritten every time a backup was made.
Know a way?
01-24-2003, 10:51 AM
Shouldn't be too hard. Just grab a timestamp from the system and use that as the filename.
Post the portion of your script where you have set the filename for the backup.
01-24-2003, 11:05 AM
$mysqldump -uusername -ppword dbname > /home/amygdala/backups/dbname-DATE.sql
01-26-2003, 10:58 AM
Anyone know how to add the date in dynamically using the command line in bash?
01-26-2003, 05:52 PM
Ok try this:
$mysqldump -uusername -ppword dbname > /home/amygdala/backups/dbname-`date +%d_%m_%y`.sql