LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-11-2006, 03:11 AM   #1
kinetik
Member
 
Registered: Dec 2005
Location: The most beautiful city in the world.
Distribution: Mostly RedHat. Also Suse, Ubuntu, PHLAK etc.
Posts: 149

Rep: Reputation: 15
Need help with creating a script-file


OK, got a big task here, could use some help...


I want to write a script that will scan certain directories (let's call it /data/1/ /data/2/ and /data/3/) on certain machines (let's call it RH1, RH2, RH3, RH4 and RH5) for logfiles, delete logfiles that are older than the current date and make a copy of today's logfile (cp logfilecurrent.log logfilecurrent.log.bak), at the same time deleting previous backups.

The twist is that should certain logfiles contain keywords such as "error" or "exception", then it should not be deleted.

The further twist is that if a logfile contains any of these keywords, that the name, path and content be e-mailed to my address (kinetik@somewhere.com).


OK, what I thought of sofar:

On RH1:

cd /data/1/
ls -lahS


...and that's how far I got! Can anyone just prod me more or less in the right direction here or perhaps even offer some coding?



Thanks!
 
Old 01-11-2006, 03:35 AM   #2
J_K9
Member
 
Registered: Nov 2004
Distribution: Slackware 11, Ubuntu 6.06 LTS
Posts: 700

Rep: Reputation: 30
Prod you in the right direction? Now, this I can do (as I have no scripting skills whatsoever)

First of all, you may want to browse through O'Reilly's Linux Command Directory - already, maybe that's a bit too long to browse... better would be to eliminate the commands you need from this quick reference and then look them up at the LCD.

You may also want to check Sourceforge.net or Google for some code - especially for the emailing bit. Coding that would take you quite a while...

For the programming bit, I suggest you learn bash. There is a great tutorial on TLDP called Advanced Bash Scripting Guide which is very comprehensive and if you follow it you'll be programming in no time!

Assuming that the same shell is running on the machines, the commands will be exactly the same for all - so no need to code it differently for another machine.

Cheers,

-jk
 
Old 01-11-2006, 03:38 AM   #3
kinetik
Member
 
Registered: Dec 2005
Location: The most beautiful city in the world.
Distribution: Mostly RedHat. Also Suse, Ubuntu, PHLAK etc.
Posts: 149

Original Poster
Rep: Reputation: 15
Thanks for the help J_K9!

Yep, all are using bash.

Any further advice still welcome everyone! The more help all of you can offer the more I'll be happy to take it. ...and give if I can one day help you out...
 
Old 01-11-2006, 08:20 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Also on TLDP: Bash Guide for Beginners by Machtelt Garrels

Excellent book to buy: Classic Shell Scripting--O'Reilly
 
Old 01-11-2006, 10:24 AM   #5
kinetik
Member
 
Registered: Dec 2005
Location: The most beautiful city in the world.
Distribution: Mostly RedHat. Also Suse, Ubuntu, PHLAK etc.
Posts: 149

Original Poster
Rep: Reputation: 15
Thanks for the help, appreciate it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
help creating a script... minm Linux - Newbie 5 01-09-2005 12:27 AM
when creating a *.iso file, how to make the file size smaller? minm Linux - Newbie 8 12-26-2004 09:58 PM
Creating a script thomas289 Linux - Networking 1 12-17-2004 11:59 AM
creating shell script that executes as root regardless of who runs the script? m3kgt Linux - General 13 06-04-2004 10:23 PM
Creating a Script? BajaNick Linux - Software 1 07-26-2003 07:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration