Crontab problem

Hi

One shell script is running fine when I am running it through command line.

However the same thing is not working when I am trying through cron.

Basically when I debugged I found when I am running it throuh ssh terminal ( putty) it's getting loading the profile file properly but through cron it's not doing the same.

Example
Code:

#!/bin/bash
. ~xcrukusr/.bash_profile_xcruk
. $XCR_HOME/cfg/.setxcrenv
. $XCR_CFG/.email_list

##-----------------------------
#debug
echo $HOME
echo "XCR Home: $XCR_HOME"
echo "XCR cfg: $XCR_CFG"
echo "$XCR_HOME/cfg/.setxcrenv"
echo "$XCR_CFG/.email_list"

output: ( through putty)

/home/xcrukusr
XCR Home: /idvprddata/xcrukusr
XCR cfg: /idvprddata/xcrukusr/cfg
/idvprddata/xcrukusr/cfg/.setxcrenv
/idvprddata/xcrukusr/cfg/.email_list

Output:(in cron)

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: line 3: /cfg/.setxcrenv: No such file or directory
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: line 4: /.email_list: No such file or directory
/home/xcrukusr
XCR Home: 
XCR cfg: 
/cfg/.setxcrenv
/.email_list

what could be the possible reason?

Here is content of .bash_profile_xcruk

# .bash_profile_xcruk
PATH=$PATH:$HOME/bin
export PS1="[\u@\h:\w \t $]"
export XCR_HOME=/idvprddata/xcrukusr
alias ptree="ps axjf"
alias pt="ps -ejH"

include the bash aliases in the current script n check

1 Like

could not get you.

Can you tell me the exact line I need to add?

(sigh) Did you ever bother to search these forums? You might have come across the solution.

1 Like

sorry about that. I should have checked.

But if you see I have already included the profile there ...

What is the content of your script:

. ~xcrukusr/.bash_profile_xcruk  

?

It seems , $XCR_HOME and $XCR_CFG are not ( are unknown to cron which mean they are not defined )!!!

1 Like

I'd use the written out pathname of the users homedirectory instead of the ~ notation.

1 Like

Extremeny sorry guys ..

Seems like when I created the new profile file it got some ^M character in it. I re-created it through VI and it's working fine now. Thanks for the help anyway.