The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Running shell scripts from web browser corleone Shell Programming and Scripting 7 07-31-2006 11:11 PM
Running SQL Scripts from Shell script - Need insight! manthasirisha Shell Programming and Scripting 6 07-03-2006 10:55 PM
unix shell scripts for running on solaris srini_ibmadmin UNIX for Advanced & Expert Users 3 06-07-2006 03:28 AM
running vendor shell scripts Javagate UNIX for Dummies Questions & Answers 1 04-13-2004 02:07 PM
Running shell scripts on a remote server pepintheshort UNIX for Dummies Questions & Answers 2 07-22-2003 04:20 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-26-2001
cfoxwell cfoxwell is offline
Registered User
  
 

Join Date: Mar 2001
Location: UK
Posts: 20
Question Cron running shell scripts.

What are the rules of calling shell scripts in cron.

How do I go about setting up the correct PATHS that calls a script, which then calls another sub script all of which has to retain the orginal PATHS and VARS that I've set up in first script

Confused..

ok
Well Cron calls a script called script.cron - This script contains environment setups etc, and then calls another script script2.ksh

I want the script2.ksh to retain all the environments etc that was set in script.cron
  #2 (permalink)  
Old 09-26-2001
giannicello giannicello is offline
Registered User
  
 

Join Date: Sep 2001
Location: Phoenix
Posts: 169
What you have should work. I have the same setup.
I kick off a script, say, first.sh which contains all the necessary paths, variables, etc and this first.sh script kicks off the next one which kicks off the next one, etc.

crontab:

00 22 * * 1-5 ksh $HOME/bin/first.sh > $HOME/log/first.log 2>&1

This has been working for as long as I can remember and I think you are on the right track.

first.sh scripts:

PATH=$PATH:/usr/bin:/usr/local/bin:$SQLDIR/bin:$HOME/bin
USERID=user01
PW=mypasswd
LOGFILE=$HOME/log/logfile.log
LIBPATH=...whatever
etc

. $HOME/bin/second.sh

you get the idea.
  #3 (permalink)  
Old 09-26-2001
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
You need to use the "export" command in the first script to put a variable in the environment. The second script will inherit the environment from its parent.

The other thing worth mentioning is that a cron script must be self-sufficient. Don't depend on setup stuff from .profile. So set variables like PATH in the script. Don't rely on the the PATH you inherit from cron.
  #4 (permalink)  
Old 09-26-2001
giannicello giannicello is offline
Registered User
  
 

Join Date: Sep 2001
Location: Phoenix
Posts: 169
I suppose you can use 'export' but my first.sh script doesn't have it and my 100 or so scripts that come after runs fine.

Also, isn't there a limit to how many processes you can chain together? After a certain amount of this type of call:

. $HOME/bin/twenty.sh

I have to do this:

ksh $HOME/bin/twentyone.sh

for recursive issues?? otherwise I get an error...Do you know why? Not sure of the exact count but to be safe I remember to use explicit calls intermittently after so many implicit calls. Don't go overboard with 'ksh' too though.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0