Cron not inherting the environment in solaris 2.5.1


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cron not inherting the environment in solaris 2.5.1
# 1  
Old 10-06-2012
Cron not inherting the environment in solaris 2.5.1

Solaris 2.5.1

I have written a shell script that creates a tar file and then ftp's the file to an other box. The shell script perfectly executes when run manually through terminal. But when i schedule it through cron, its not executing and showing exit code RC =1 in cron log.

I have added the 2 lines cd / and . . profile per the research i did, but still wont execute when schduled in cron
Code:
#!/bin/sh

cd /

.  . profile

{
   create tar file  function
}

{  
   ftp function
}

Appreciate if anyone can point what is wrong and throw a few lines..

Venu

Last edited by fpmurphy; 10-09-2012 at 11:19 AM.. Reason: code tags please!
# 2  
Old 10-06-2012
I would think that you'd want to source the profile from your home directory; I doubt that one exists in /

Try:

Code:
. $HOME/.profile

Or use the absolute path to .profile if it's not in your home directory.
# 3  
Old 10-07-2012
First thing I'd say, is it the tar creation or the ftp that fails to run under cron?

Where are you expecting the cron job to get the ftp login credentials from?
# 4  
Old 10-08-2012
Thanks to everyone for watching this thread. i found a wiki on this website detailing cron and how to troubleshoot.

Problem solved

Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

My active tickets will not be available in the cron environment

Hi everybody , when I run a script from the command line it works but returns a failure if I run it from crontab. Basically I wanted to send a file to hdfs, I thought it was related to the fact that crontab do not know the path to hdfs so I put the full path but it still does not work: here... (1 Reply)
Discussion started by: beautymind
1 Replies

2. Solaris

Setup print environment in Solaris 11

Hi Experts, Please help me on this. I've a print environment using NIS in Solaris 10. Recently we have new JDE environment which using Solaris 11 OS, and found that we can't use NIS anymore. So only the option is using CUPS. How do we integrate this print environment for both Solaris 10... (9 Replies)
Discussion started by: srigias
9 Replies

3. Solaris

Unique ID on Solaris in visualized environment?

Hi I need to know what is the unique identifier for solaris OS even in a virtualized environment? Will "Using Universally Unique Identifiers" help? virtinfo -u Domain UUID: 9db53f14-f27c-69f9-a71c-8926e9ae6eed If Not, then let me know? Would appreciate if similar UNIQUE id (of... (3 Replies)
Discussion started by: skyineyes
3 Replies

4. Solaris

Back up solution in Solaris 10 environment

Hi Friends, Good day! This is my first post in this forum :) In my company we have a requirement for back up application specific files and directories .We have around 40+ application which needs to be backed up .All these applications are running on Solaris 10 enviornment. Is... (8 Replies)
Discussion started by: Abilash_KP
8 Replies

5. Shell Programming and Scripting

Run script through cron with user environment variables

Hi everyone, I wrote a script that is supposed to be run by cron on a daily basis. It works just fine if I run it manually, but due to a lack of environment variables (which are available during my user session but not when cron runs the script) it keeps failing to run successfully. Here's the... (2 Replies)
Discussion started by: gacanepa
2 Replies

6. Solaris

Environment variables and cron

where do you set environment variables for cron jobs? I have a feeling it would ignore ~/.bashrc ? thanks. (2 Replies)
Discussion started by: orange47
2 Replies

7. Shell Programming and Scripting

Setting environment variables in Cron file

Hi, In Cron file i'm using username and password hard-coded and now i wann to use environmental veraiables in cron file. But Could you please guide me how to use these environmental variables in cron file ? Thanks, Shyamu.A (4 Replies)
Discussion started by: shyamu544
4 Replies

8. UNIX for Dummies Questions & Answers

Solaris 10.0 PATH environment

Hello, I am using Solaris 10.0 and defining PATH on command line by the following way: #export PATH=/usr/sfw/bin.... ...but after restart, Solaris forgets what I defined and I need to re-define the same PATH environment. I want to to get defined my PATH environment during booting... (10 Replies)
Discussion started by: XNOR
10 Replies

9. Solaris

Setting environment variables within cron jobs!!

Is it possible to use environment variables within cron jobs. I am using a cron job to run a c program at regular intervals. The C program uses a library and i have set the library path in the LD_LIBRARY_PATH environment variable. But when i ran the job i got the error library not found!! Any... (1 Reply)
Discussion started by: atheek
1 Replies

10. UNIX for Dummies Questions & Answers

Cron Environment

I am trying to run a series of perl scripts at different times using crontab under solaris. The scripts that i am using require some specific environment variables to be specified for database functionality, but i would also like it that i can specify a few global variables for output locations. ... (8 Replies)
Discussion started by: Smitty McSmith
8 Replies
Login or Register to Ask a Question