Cron Job to Email Contents of Log File

Status
Not open for further replies.

Wardy118

Cadet
Joined
Apr 27, 2016
Messages
6
Hello,

I'm relatively new to FreeNAS, but I know my way around quite comfortably now. I've recently encountered the phenomenon of multiple people attempting to access my server, as I had port 22 open on my router. I've since remedied this by using a different port. However, i'd like to see the auth.log (/var/log/auth.log) on a daily basis, at least for a few days just to be sure.

My understanding is that a cron job can be used to automate tasks, and I'd like to be able to receive an email of this log on a nightly basis. Is this the case? If so (or if not), how would I go about doing this? I've looked at the syntax of some cron jobs, but they all relate to writing the output of a command to a log, rather than email an existing one.

Many thanks.
 

Sakuru

Guru
Joined
Nov 20, 2015
Messages
527
If you have your email configured under System --> Email you can use the sendmail command.
Code:
cat /var/log/auth.log | sendmail -i something@somewhere.abc
 
Status
Not open for further replies.
Top