Automatic Email of Log Files in OSX


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Automatic Email of Log Files in OSX
# 1  
Old 12-23-2010
Automatic Email of Log Files in OSX

Hi,

I am trying to write a shell script that will take the log files from a single folder (all ending with .log), put them into an archive, use something to encrypt the file, and then emailx to email the resulting encrypted archive to me.

Of course, I am open to suggestions on how to improve this process. Essentially, I need this script, when run, to email me log files in a secure way.

Or, even better, if the script could run automatically. But I'll worry about that later.

So far....
Code:
#! /bin/sh

logPath="/PHSLogs"
archiveName = `date {y}--{m}--{d}_{h}-{m}-{s}`

gzip -r $logPath    <--- How do I specify that I want the archive name to be $archiveName?

#What do I use to add some form of strong-ish encryption to the archive?

#What would be the appropriate syntax for emailx? Or is there a better way to transfer the file back to me?
mailx -s "$archiveName" user@domain.com < $logpath/log.gz

Seems strange, I know. It's for a very particular task at work I'm working on. Rather than spending hours trying to figure this out, I was hoping to receive some help along the way. Thank you so much for your time.

Edit: Added what I think should work for emailx syntax.

Last edited by DotNaBox; 12-23-2010 at 04:23 PM..
# 2  
Old 12-23-2010
Code:
archiveName=`date +%Y-%m-%d_%H-%M-%S`

tar cvf - $logPath |gzip > $logPath.$archiveName.tar.gz

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. OS X (Apple)

Help: Add email users in OSX terminal

Please forgive me if this is the wrong place to post. I am a VERY basic user here and have been tasked with adding a user to our email system -- we use a squirrelmail interface and I have root passwords etc. I tried logging in through a browser but get this error: ERROR: Connection... (1 Reply)
Discussion started by: dperro01
1 Replies

2. UNIX for Dummies Questions & Answers

Help: Add email users in OSX terminal

Please forgive me if this is the wrong place to post. I am a VERY basic user here and have been tasked with adding a user to our email system -- we use a squirrelmail interface and I have root passwords etc. I tried logging in through a browser but get this error: ERROR: Connection dropped... (1 Reply)
Discussion started by: dperro01
1 Replies

3. Shell Programming and Scripting

Shell script for sending automatic email to personal mail id

hi guys, I need a shell script to send mail automatically to my personal mail id like xxxx@hotmail.com but while experimenting with "mail" command I faced following problems. cat text1.txt | mail -s 'test mail' xxxx@hotmail.com command successfully executed but while checking for... (4 Replies)
Discussion started by: rrd1986
4 Replies

4. OS X (Apple)

OSX: Syncing VERY large video files across web

My impressions from recent web explorations has me questioning the appropriateness of rsync ( or rsyncx ) for syncing large video/movie files to remote locations. Background: A friend who edits and creates movies would like to sync his video files from his place of business to his home. These... (2 Replies)
Discussion started by: Bubnoff
2 Replies

5. Shell Programming and Scripting

Email script when automatic backup is finsihed

Hello all, i'm still new to this site and thought i might find some help here :). lately i performed a script to make an automatic backup of some files in certain directories. the script looks something like this: #! /bin/bash ##############VARIABLES path=/export/home/cassi/Backup... (5 Replies)
Discussion started by: Wizard_1979
5 Replies

6. OS X (Apple)

Automatic device recognition in OSX

Can anyone point me to a resource (or answer my question) that will show me how to automatically run a script in OSX when a device is plugged in. The OS recognizes that the device is plugged in but how do I direct it to do something I want it to do. it seems that linux has udev but what would... (2 Replies)
Discussion started by: djkuzenko
2 Replies

7. UNIX for Dummies Questions & Answers

where are my email log files

I am trying to find the email log file that would have info on users downloading their pop mail. Our email is hosted on a unix server running apache. I am not sure the exact version of mail software running, but when I telnet to the mail server the response I get is this "+OK POP3 v2003.83rh... (3 Replies)
Discussion started by: mstarcom
3 Replies

8. Shell Programming and Scripting

Script for automatic deletion of old files

Hi, I have a folder with limited space. I do not have provisions to increase the space for this folder. So i have to delete files which are more than 1 month old automatically. But, i need to maintain the files created by 4 users and delete all the other files automatically which is more than 1... (4 Replies)
Discussion started by: vivek_scv
4 Replies

9. Solaris

Automatic Log files to my E-mail.

Hi, I have 6 servers, I want to make a script to read the messages (/var/adm/messages) file daily in the morning and send it automatically to my E-mail address. Regards (2 Replies)
Discussion started by: adel8483
2 Replies

10. Shell Programming and Scripting

automatic transfering of files using scp

I'm in the process of writing a shell script with copies files from one linux box to another using scp. I wish to run this through a cronjob so it cannot be interactive. This is what I have so far. #!/bin/sh PASSWD='passswd' dateset=$( date | awk '{print $2 $3 $6}') for dates in $dateset;... (1 Reply)
Discussion started by: tcruicksh
1 Replies
Login or Register to Ask a Question