Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-29-2011, 09:15 AM   #1
Registered: Apr 2008
Posts: 108

Rep: Reputation: 15
Smile 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:

/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
Old 12-29-2011, 12:05 PM   #2
Registered: Jun 2007
Distribution: Debian, SLES, Ubuntu
Posts: 308

Rep: Reputation: 50
Try putting in the full path for lastb rather than relying on a path to be set. example: /usr/bin/lastb
Old 12-29-2011, 03:31 PM   #3
Registered: Apr 2008
Posts: 108

Original Poster
Rep: Reputation: 15
Smile 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
Old 12-29-2011, 03:42 PM   #4
Senior Member
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 243Reputation: 243Reputation: 243
man ausearch
    Use the log file location from auditd.conf as input for searching. 
    This is needed if you are using ausearch from a cron job.
Old 12-30-2011, 06:29 PM   #5
Registered: Apr 2008
Posts: 108

Original Poster
Rep: Reputation: 15
Smile Will let you know


I will try this next week and post what happens. Thanks for the advice.
Johnny Mac
Old 01-08-2012, 06:54 PM   #6
Registered: Apr 2008
Posts: 108

Original Poster
Rep: Reputation: 15
Cool 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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Script runs if executed from CL, not from Cron Ravendark Programming 6 10-13-2010 06:07 AM
Script runs manually but not from cron redvelo Linux - Newbie 6 09-29-2010 01:37 PM
Script not running properly in cron though runs well if run manually. linuxlover.chaitanya Linux - Newbie 4 01-15-2009 03:31 AM
Script works when run manually but not in cron job Harlin Linux - Software 7 10-16-2007 06:36 PM
script doesn't run in cron (runs from shell just fine) Timur Sakayev Linux - Software 6 02-26-2007 12:56 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:26 PM.

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