Click to See Complete Forum and Search --> : Output To A File


Dark Ninja
10-29-2001, 11:52 AM
I recently installed Tripwire on my system, and, I want to run a security check once a night to make sure nothing has been changed on my system. (At least - nothing that shouldn't be changed, hasn't been changed.)

Anyway, I'd like to automate this proceedure, so I figured a bash shell script would be the best way.

I want the script to be able to run Tripwire, and then output the results to a file in a specific directory (already created by me). I also want the script to run every night at 3:00 AM.

Now, here's my script so far:

#!/bin/bash
tripwire -m c > /specified/directory/file.txt


First off, is this correct? Also, will it append to file.txt, or will it overwrite file.txt. (Append is what I am hoping for.)

My biggest problem, however, is getting it to run every night at 3. I know this involves crond, but, how would I set that up? I have almost no familiarity with crond.

Thanks for any help.


Dark Ninja

slacker_x
10-29-2001, 12:16 PM
put the shell script in /etc/cron.daily
the format of the command should be:
command >> /path/to/file.txt

you can change the time that the files in cron.daily run at by modifying /etc/crontab

it would look something like this:


00 3 * * * root test -e /usr/sbin/anacron || run-parts --report /etc/cron.daily


I think it's Debian specific, but there may be an /etc/cron.d directory for running scripts at an arbitrary time. The scripts in that directory have the same format as the lines in /etc/crontab.

Etherphyte
10-29-2001, 12:22 PM
Well, for starters, turn the > to a >> to append the file. Second, your crash course in cron:
execute the command crontab -e <user>, this is how you edit a user's cron. In this case, the user is whatever user is invoking tripwire.
Add the line:
* 3 * * * tripwire -m c >> /what/ever/file
exit your editor and you are good to go.

I am not an expert on this, so feel free to correct me if i am wrong on this ;)

Check
this (http://www.uwsg.iu.edu/usail/automation/cron.html#crontable)for a good cron how-to
-ad

X_console
10-29-2001, 01:33 PM
program > myfile.txt will overwrite the previous contents of myfile.txt

program >> myfile.txt will append to the previous contents of myfile.txt

program 2> myfile.txt will overwrite the previous contents of myfile.txt with any error messages that the progam gets.

program > myfile.txt 2> myerrors.txt will result in overwriting the contents of myfile.txt with non-erroneous output, and overwriting the contents of myerror.txt with any errors generated by the program.

Hope that helped.