The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
cronjob inside the script namishtiwari Shell Programming and Scripting 3 02-04-2008 04:35 AM
Nested loop not running using cronjob bihani4u Shell Programming and Scripting 9 09-26-2007 08:19 AM
help help cronjob problem with script bucci Shell Programming and Scripting 4 02-10-2007 12:38 AM
Shell script not running thru Cronjob gauravshrinivas Shell Programming and Scripting 8 11-03-2006 06:17 AM
Environment variables causing cronjob to fail new2ss Shell Programming and Scripting 2 05-31-2006 08:58 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-19-2006
csaha's Avatar
Registered User
 

Join Date: Feb 2005
Posts: 81
Variables are not getting exported while running the script in cronjob

Hi All

Some how, variables are not getting exported while running the script in cronjob. Variable value is coming blank. But the variables are geting the value when the same script I am running manually. Any idea why?

When running the script in cron-job
==================================
user@server:~$ crontab -l
00 22 * * * $HOME/crt-offline-chkpnt.sh

When running the script manually
==================================
user@server:~$ ./crt-offline-chkpnt.sh

Thanks a lot to all in advance
C Saha
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-20-2006
csaha's Avatar
Registered User
 

Join Date: Feb 2005
Posts: 81
actually the file and the o/p is like this

$ cat crt-offline-chkpnt.sh

P4_COUNTER=`p4 -u cm -P cmpswd counters | grep journal | awk '{print $3}'`
echo "$P4_COUNTER" >aa.log

$ ./crt-offline-chkpnt.sh
$ cat aa.log
1157

No output when I have it in cronjob :-(

Last edited by csaha; 02-20-2006 at 02:21 AM.
Reply With Quote
  #3 (permalink)  
Old 02-20-2006
Registered User
 

Join Date: Dec 2005
Location: India
Posts: 218
Hi,

have you checked the aa.log file, whats going in it
and post your cron entry as well

Gaurav
Reply With Quote
  #4 (permalink)  
Old 02-20-2006
csaha's Avatar
Registered User
 

Join Date: Feb 2005
Posts: 81
SORRY for the typo error in my previous post.

Yes I saw aa.log, its coming blank when its running by cronjob

This is cron settings

When running the script in cron-job
==================================
user@server:~$ crontab -l
00 22 * * * $HOME/crt-offline-chkpnt.sh
Reply With Quote
  #5 (permalink)  
Old 02-21-2006
Registered User
 

Join Date: Feb 2006
Posts: 61
you may want to consider using explicit paths instead of paths with variables in them. quite honestly, i've never seen variables used in a cron table before.

if anything, you may want to check to see if:
1. your script is running at all (check your local mailbox for cron errors(

and

2. put in the full path to your 'p4' command.
Reply With Quote
  #6 (permalink)  
Old 02-21-2006
Registered User
 

Join Date: Feb 2006
Location: Mumbai, India
Posts: 24
Also try including your profile in the script your are calling via cron
Reply With Quote
  #7 (permalink)  
Old 02-21-2006
csaha's Avatar
Registered User
 

Join Date: Feb 2005
Posts: 81
Yes exactly. Both of your suggession worked. Its fine now.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:43 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0