LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 01-11-2010, 06:41 PM   #1
venkatramanj
LQ Newbie
 
Registered: Jan 2010
Posts: 1

Rep: Reputation: 0
Shell Script not Running from Crontab


Hi All,

I have a shell script which is configured for the user. The main task of the shell script is to email certain user with a particular result.

The shell script runs perfectly when run from a Konsole terminal and configured through a crontab generates empty entries.

Below is my crontab for my user.

Code:
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.XXXXSyNyp1 installed on Wed Jan  6 09:14:14 2010)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
#!/bin/bash
#
# Minute (0-59), Hour (0-23), Day (1-31), Month (1-12), Day of Week (0-7)
#
*/5 * * * *     /home/bldteam/bin/vmail_summary_findbugs.sh
vmail_summary_findbugs.sh
Code:
#!/bin/bash

FRAMEWORK=`cat ~/public_html/checkstyle/results/psw/projects/core.framework/reports/find_bugs.txt | parse_find_bugs`
COMPONENTS=`cat ~/public_html/checkstyle/results/psw/projects/core.components/reports/find_bugs.txt | parse_find_bugs`
PSW=`cat ~/public_html/checkstyle/results/psw/projects/psw/reports/find_bugs.txt | parse_find_bugs`
HDAV=`cat ~/public_html/checkstyle/results/hdav/projects/hdav/reports/find_bugs.txt | parse_find_bugs`

echo "Report taken from:  http://tcl00012/checkstyle/

===== Core Framework =====

$FRAMEWORK

===== Core Components =====

$COMPONENTS

===== PSW =====

$PSW

===== HDAV =====

$HDAV" | 

mail -s "[ALERT] Venue Software FindBugs Summary by Class" vjayara9@rockwellcollins.com

Last edited by XavierP; 01-12-2010 at 03:15 AM.
 
Old 01-12-2010, 09:25 AM   #2
bradvan
Member
 
Registered: Mar 2009
Posts: 367

Rep: Reputation: 61
You are not mailing anything. It looks like you are just displaying to standard output. You need to redirect those to a log and then mail the log file.
 
Old 01-12-2010, 02:18 PM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You have to use the full path for "parse_find_bugs" otherwise the cron daemon cannot find it. Take in mind that cron has a very limited environment and the PATH is usually /bin:/usr/bin. For this reason - as a general rule - it's better to use the full path of each command inside the scripts you run from crontab.

@bradvan: maybe you missed the last line of the script, where all the output from echo is piped to mail.
 
Old 01-13-2010, 05:15 AM   #4
bradvan
Member
 
Registered: Mar 2009
Posts: 367

Rep: Reputation: 61
I did miss it!

But I agree about full paths. I usually define a variable giving the complete path to the command and then use that throughout my script. It also makes it easier when supporting more than one OS. For example:
Code:
if [ `uname -s` = "Linux" ]; then
   SED=/bin/sed
else
   SED=/usr/bin/sed
fi
 
  


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
Runs Multiple shell script inside a main script using crontab srimal Linux - Newbie 4 10-22-2009 06:19 PM
Shell script not working through crontab paragkalra *BSD 1 04-15-2009 12:36 PM
Running a script with crontab. glore2002 Slackware 3 06-05-2008 08:48 PM
how to run crontab in shell script panselva Linux - General 3 05-08-2008 08:33 PM
Shell script running via crontab problem. thetruethugg Linux - Software 13 12-19-2003 08:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

All times are GMT -5. The time now is 12:42 AM.

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
Open Source Consulting | Domain Registration