LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Script runs Manually but not in Cron, yet other parts of the script run (https://www.linuxquestions.org/questions/linux-newbie-8/script-runs-manually-but-not-in-cron-yet-other-parts-of-the-script-run-921067/)

mccartjd 12-29-2011 09:15 AM

Script runs Manually but not in Cron, yet other parts of the script run
 
I have script that runs if I execute it as root manually but when I direct it to run in a script the file size is always 0. See below:

#!/bin/bash
/sbin/ausearch -i -ts week-ago -k open --success no >/audits/open.txt
lastb -n 35 >/audits/failedlogin.txt

The line lastb -n 35 >/audits/failedlogin.txt results in a output file and it works but the line
/sbin/ausearch -i -ts week-ago -k open --success no >/audits/open.txt only results in a new file with nothing in it however if I run it manualy the file is populated?

Is this an enviornmental issue when cron is run? A million thanks in advance, Johnny Mac

grim76 12-29-2011 12:05 PM

Try putting in the full path for lastb rather than relying on a path to be set. example: /usr/bin/lastb

mccartjd 12-29-2011 03:31 PM

Lastb works
 
The lastb portion of the script works but not the below:

/sbin/ausearch -i -ts week-ago -k open --success no >/audits/open.txt

Cedrik 12-29-2011 03:42 PM

man ausearch
Code:

--input-logs
    Use the log file location from auditd.conf as input for searching.
    This is needed if you are using ausearch from a cron job.


mccartjd 12-30-2011 06:29 PM

Will let you know
 
Cedrik,

I will try this next week and post what happens. Thanks for the advice.
Johnny Mac

mccartjd 01-08-2012 06:54 PM

Sorry that did not work
 
Runing a serach and directing the path did not work (same results). I also osed the if option and results were the same.

Oh well.


All times are GMT -5. The time now is 03:25 AM.