Problem with Cron job


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with Cron job
# 1  
Old 11-23-2009
Question Problem with Cron job

Hi ,
I have a TCL script which i am supposed to run as a cron job..
The script works fine from command line , but when run as a cron job , its unable to find a package,,
my crontab is as follows.
---------------------------
#!/usr/bin/ksh
* * * * * PATH=/cm8/auto/Automation/Library/TclLib

0,10,20,30,40,50 * * * * /home/users/sudharss/bin/tclsh /home/users/sudharss/AUTO/ontDownload.tcl

my tcl script is as follows
-----------------------------

#!/usr/bin/ksh
# \
exec tclsh8.3 "$0" ${1+"$@"}
global env
global auto_path
if { [info exists env(arch)] && $env(arch) == "linux" } {
lappend auto_path "/cm8/auto/Automation/Library/TclLib-Linux"
} elseif {[info exists env(arch)] && $env(arch) == "sunos" } {
lappend auto_path "/cm8/auto/Automation/Library/TclLib"
} else {
puts "arch type not known, defaulting to sunos"
lappend auto_path "/cm8/auto/Automation/Library/TclLib"

}

package require mysqltcl


the o/p of cron is as follows
------------------------------
Your "cron" job on inchesfttu003-c1
/home/users/sudharss/bin/tclsh /home/users/sudharss/AUTO/ontDownload.tcl

produced the following output:

arch type not known, defaulting to sunos
hi
can't find package mysqltcl
while executing
"package require mysqltcl"
(file "/home/users/sudharss/AUTO/ontDownload.tcl" line 17)

can someone please help.....
# 2  
Old 11-23-2009
Environment when called from cron is different to when called from a shell. These questions regarding cron are so often asked, you might want to use the forum's search function and have a look here:
https://www.unix.com/answers-frequent...n-crontab.html
# 3  
Old 11-23-2009
Ok check these

1. line ---> exec tclsh8.3
->> Is the complete path required here also ?
2. add PATH to your crontab. Just add PATH=Bla BLA ... (whatever your path is)
3. Incase you dont like add PATH to crontab ... then add to your script (different script using different paths in cron) ..
->> Add a line export PATH= BLA BLA (whatever your path is)
# 4  
Old 11-23-2009
Hi , I have added the path also in my crontab...
But still it doesnt work. I have tried out numerous solutions from related posts, but nothing seems to work.
# 5  
Old 11-23-2009
how about 1 & 3 suggested ... have you tried these also ?
# 6  
Old 11-23-2009
Yes i have tried but in vain

---------- Post updated at 07:07 AM ---------- Previous update was at 07:03 AM ----------

I have this auto_path, a global TCL variable(not an ordinary env variable) in my tcl script, and i have set it to the path where the mysql files are located.
lappend auto_path "/cm8/auto/Automation/Library/TclLib"

But I feel the cron is unable to see that variable!!! I am confused how to make cron identify where to look for the mysqltcl lib files.Because its throwing error at that point where i call "package requires mysqltcl "

---------- Post updated at 07:09 AM ---------- Previous update was at 07:07 AM ----------

It can also be seen that normal TCL commands like puts etc are working..
only when it comes to the "package requires mysqltcl" , its showing error.. The variable auto_path holds the PATH to this lib
# 7  
Old 11-23-2009
I have not done much TCL ... but do you have something similar to path for package like @INC or PERL5LIB on env.

example:
set dir /path/to/specific/version/of/extension ....

like on URL: Tcl Modules

Another solution I would try ..
When everything fails and I am only one in prod incharge Smilie (try at your own risk)

take all the environment variables and put it in a file and source that in shell script
set > ~/allenvvar.sh

and in script
source ~/allenvvar.sh

Then once it starts to work ... remove one variable at a time..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execution problem with CRON job

HI, I have written an executable file in unix and I was able to execute it successfully but when I called this file with cron job it was giving error like "permission denied" and "No such file or directory". Please help in how cron calls the file and what permission is required on the file... (2 Replies)
Discussion started by: vipin kumar rai
2 Replies

2. Solaris

Problem with a cron job

When i am trying to open crontab throught command crontab -e. It is not opening? OUTPUT: # crontab -e sh: vim: not found The crontab file was not changed. Please let me know how to open and edit it??? (10 Replies)
Discussion started by: kkalyan
10 Replies

3. UNIX for Dummies Questions & Answers

Cron job problem

I have a perl script which Im planning to run every minute. I have set the cron job as * * * * * PATH= /usr/local/bin:/usr/bin:/usr/sbin:/usr/lib; perl /dm2/www/html/isos/pre5.3/autoDownload.pl I assume the script is executing every minute only because I see a entry like below when I do... (2 Replies)
Discussion started by: srijith
2 Replies

4. UNIX for Dummies Questions & Answers

EOF problem with Cron Job?

Hey guys... first post here... I have set up the following cron to create daily backups for me and rotate them weekly: date=`date +%d`; tar -zcvf /home/mysite/backups/backup_dev_$date.tgz /home/mysite/public_html/dev/app --exclude=/home/mysite/public_html/dev/app/tmp However, I keep... (4 Replies)
Discussion started by: Crazy Serb
4 Replies

5. Shell Programming and Scripting

Scheduling Cron job-Problem

Hello All, I want to run a script for every 5 minutes interval.So i developed a script which has to be scheduled to run for every 5 minutes. That script internally runs another script. But the problem is it is not executing properly. Can anybody throw some light on this. Below are the code... (4 Replies)
Discussion started by: RSC1985
4 Replies

6. UNIX for Dummies Questions & Answers

cron job problem(urgent)

Hey all. Im totally new with makeing websites ect The thing is, i wanted to make one of those pimp games, so i installed a script called mypimpscript.. it works but the 10mins cron jobs dont... ive tried to set it up in cpanel, but im doing it wrong :S right now it looks like this php... (1 Reply)
Discussion started by: princess
1 Replies

7. Solaris

problem with cron job

new to unix here, im learning how to schedule jobs with crontab. The following cron job runs under root but not under a test account i created. 50 11 * * 0 /usr/bin/banner "HELLO" > /dev/console i have no idea with it isn't running under the test account but runs right on time when i create... (7 Replies)
Discussion started by: solne
7 Replies

8. Solaris

cron job problem

I am trying to setup cronjob and once I start to save it is not working. This is what I am getting after I executed crontab -e, I am not even getting the privious entry and I am running from root. crontab -e 421 10 3 * * * /usr/sbin/logadm ? :wq ? Why is it not saving? Any input is... (4 Replies)
Discussion started by: mokkan
4 Replies

9. UNIX for Advanced & Expert Users

Cron job skipping problem

Hi, I have a crontab that runs some shell scripts at fixed intervals. Although, one condition for a script to continue is that a previous instance of the same script should have terminated. But, inspite of the fact that the old instance has finished execution, the new instance still terminates. ... (3 Replies)
Discussion started by: puneetarora_12
3 Replies

10. UNIX for Advanced & Expert Users

Run cron job problem

I have the below crontab job that it will run at every 7:00am - 10:00am , it work fine , now if I want to skip to run the crontab job at a specific time , eg. I want the script not to run at next Monday 8:00am ( only skip this time , other time is normal ) , how can I make it ? is it possible ?... (3 Replies)
Discussion started by: ust
3 Replies
Login or Register to Ask a Question