Computing.Net > Forums > Unix > crontab & ksh functions

crontab & ksh functions

Reply to Message Icon

Original Message
Name: tschau
Date: November 8, 2007 at 10:11:19 Pacific
Subject: crontab & ksh functions
OS: AIX
CPU/Ram: 5 GB
Model/Manufacturer: IBM
Comment:

I have all my functions stored in a file and normally I would just “source” them at the beginning of my scripts. This was working as expected until I tried to run a script using crontab. It seems to me as soon as I try to do something like “. <my file>”, whatever follows will just get ignored. For example, I have the following test script:

echo "before" > /tmp/tchaulog
. /home/tchau/bin/funcs.ksh
echo "after" >> /tmp/tchaulog

After the run, I only see “before” in the log file.

Would anyone be able to help me get around this problem? Your help is much appreciated. Thanks.

TS Chau


Report Offensive Message For Removal


Response Number 1
Name: nails
Date: November 8, 2007 at 10:39:54 Pacific
Subject: crontab & ksh functions
Reply: (edit)

When a script runs from the command line, but fails from cron, it's because the environment isn't the same.

1) Make sure your environmental variables such as PATH are defined in the script. Cron's environment is different.

2) Since you apparently are using ksh, make sure that each script has the shell invocation:

#/bin/ksh

at the top of each script (line 1). cron, in my cases, uses the Bourne shell, sh, by default.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: crontab & ksh functions

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge