LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices



Reply
 
Search this Thread
Old 12-29-2011, 10:15 AM   #1
mccartjd
Member
 
Registered: Apr 2008
Posts: 107

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:

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

Rep: Reputation: 47
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, 04:31 PM   #3
mccartjd
Member
 
Registered: Apr 2008
Posts: 107

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, 04:42 PM   #4
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
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.
 
Old 12-30-2011, 07:29 PM   #5
mccartjd
Member
 
Registered: Apr 2008
Posts: 107

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

Cedrik,

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

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.
 
  


Reply


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 07:07 AM
Script runs manually but not from cron redvelo Linux - Newbie 6 09-29-2010 02:37 PM
Script not running properly in cron though runs well if run manually. linuxlover.chaitanya Linux - Newbie 4 01-15-2009 04:31 AM
Script works when run manually but not in cron job Harlin Linux - Software 7 10-16-2007 07:36 PM
script doesn't run in cron (runs from shell just fine) Timur Sakayev Linux - Software 6 02-26-2007 01:56 PM


All times are GMT -5. The time now is 08:52 PM.

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