Help with cron job


 
Thread Tools Search this Thread
Operating Systems AIX Help with cron job
# 1  
Old 01-16-2010
Help with cron job

Hi guys and gals,

I have this script that run perfectly when executed manually. If I place it in a cron to run on a schedule, it fails. Error is:

Code:
exec(): 0509-036 Cannot load program /usr/local/bin/getlogical because of the following errors:
        0509-150   Dependent module libclntsh.a(shr.o) could not be loaded.
        0509-022 Cannot load module libclntsh.a(shr.o).
        0509-026 System error: A file or directory in the path name does not exist.

I'm using absolute paths in the crontab. Why would it run fine when executed manually and fail in a cron?
# 2  
Old 01-16-2010
cron fails

Dear friend ,

pls give details abt cron entry..
# 3  
Old 01-16-2010
Quote:
Originally Posted by bbbngowc
[...]I'm using absolute paths in the crontab. Why would it run fine when executed manually and fail in a cron?
That would happen if you use different environments. Make sure the cronjob is run as the same user that can run the script from commandline. If you want to run the script as a different user from cron you either need to source the environment* of the user who can run the script or adapt the cron user's environment to the commandline user's.

* Lookup the dot command
# 4  
Old 01-16-2010
Here is the entry in fron the crontab

Code:
$ crontab -l
57 8 * * * /path/to/script.sh > /path/to/script.sh_01162010.log 2>&1



---------- Post updated at 09:03 AM ---------- Previous update was at 08:58 AM ----------

Quote:
Originally Posted by shockneck
That would happen if you use different environments. Make sure the cronjob is run as the same user that can run the script from commandline. If you want to run the script as a different user from cron you either need to source the environment* of the user who can run the script or adapt the cron user's environment to the commandline user's.

* Lookup the dot command
I am running the script as the same user.
# 5  
Old 01-16-2010
Hi bbbngowc,
When you exucute something from cron you don't have the same evironment setup as you do when you execute it from the command line when you are logged in. For instance I have a command that I can execute from the command line like this:
Code:
jqsubmit -jlawis lawadm spendcompa

I can do that by itself because when I log in there is a command in my profile (located in my home directory) that gets executed to set up the environment needed to execute it. The command is:
Code:
 . cv lawprod

Now to execute the first command from cron I have to set up a file combining the two commands like this:
Code:
. cv lawprod
jqsubmit -jlawis lawadm spendcompa

I then execute the above file from cron. I believe that is what shockneck was trying to explain.
# 6  
Old 01-17-2010
Is there a way I can make my script environment independent? So it'll run regardless of the user and regardless of the cron or otherwise?
# 7  
Old 01-17-2010
Yes, pretty simple actually. Just set up the environment you need yourself, at the beginning of the script. If you need the same for more than one script, put the set-up into a separate script & source it at the beginning.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cron job - Need to run Cron every quarter at particular time

Hi, 1) If some job supposed to run on 1st of every month at 7 AM In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day? 2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct) And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies

2. UNIX for Dummies Questions & Answers

Cron Job

How to schedule a cron job to run every other Monday. Thanks in advance. (2 Replies)
Discussion started by: ITDev01
2 Replies

3. Shell Programming and Scripting

Commented cron job -- cron monitoring

Hi I have a requirement to write a shell script,that will check the all commented job in cron job.Please help !! (2 Replies)
Discussion started by: netdbaind
2 Replies

4. Solaris

Cron job running even after cron is removed

Hi , I have removed a cron for particular user , but cron job seems to be running even after the cron entry is removed. The purpose of the cron was to sendmail to user ( it uses mailx utility ) I have restarted cron and sendmail service still user is getting mail alerts from the cron job. And... (4 Replies)
Discussion started by: chidori
4 Replies

5. UNIX for Advanced & Expert Users

cron job

Hello, Can anyone help me how to set any script as cron job. I have gone through all threads but not able to get the details. Appreciate your help. I need to set test.pl to run on every Tuesday by 6am in the morning. I do not the cron file which is defined. Please help me out. ... (3 Replies)
Discussion started by: jam_prasanna
3 Replies

6. Solaris

cron job starts new cron proccess

I run cron in solaris 10 zone. One cron job which syncing files to nfs mounted on container, creates after finishing another cron proccess(/usr/sbin/cron), and after 100 existing cron proccesses next cron job will not start. It's too weird for me, I'm not able to solve this problem. Theoretically... (3 Replies)
Discussion started by: ron76
3 Replies

7. UNIX for Dummies Questions & Answers

CRON usage for CRON job

can anybody explain the usage of CRON for adding a cron job. please provide an example also for better understanding !!! Thanks (1 Reply)
Discussion started by: skyineyes
1 Replies

8. UNIX for Dummies Questions & Answers

Cron job

Regarding Cron job, i want to execute a scriptevery 4 days once irrespective of a week or a month. Is it possible?Any help (2 Replies)
Discussion started by: santho
2 Replies

9. Shell Programming and Scripting

Cron job

Hi All , We have few scripts which uses common environment/path setting variables. Now instead of putting classpath , framework,java_home ..... etc. in all the script, can we make a file with all common settings which can be envoked by the scripts while running. If yes , say setting file is... (3 Replies)
Discussion started by: pankajkrmishra
3 Replies

10. Shell Programming and Scripting

Cron job

Hi All I am trying to run a .sh file from cron but its not performing its intended purpose, though the same sh file works fine when triggered manually.Following mail I recieve when it tries to run the script. ********************************************************* To: wlsdev05 Subject:... (16 Replies)
Discussion started by: pankajkrmishra
16 Replies
Login or Register to Ask a Question