Solved

Why does it work on command line but no cron ?

Posted on 2006-06-16
5
238 Views
Last Modified: 2013-12-16
This crontab entry works fine on command line but as i put it in cron it errors:
with
20060616 15:03:00 ##### tidy_backup.sh: Starting Process
20060616 15:03:00 ##### tidy_backup.sh: Exporting ORACLE_SID as IF9P1
20060616 15:03:00 ##### Obtaining Passwords
20060616 15:03:00 ##### tidy_backup.sh: ERROR  !! PLEASE INVESTIGATE !!!

Does cron have a different enviroment to command line
0
Comment
Question by:hraja77
  • 3
5 Comments
 
LVL 43

Expert Comment

by:ravenpl
ID: 16920681
> Does cron have a different enviroment to command line
Yes. Usually problem is in env PATH variable. Script run from command line has it's commands in PATH, while run from cron has not.
SOmetimes, commands requires TTY - cron supplies none.
0
 
LVL 1

Author Comment

by:hraja77
ID: 16920890
what is TTY
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 16921760
TTY - text terminal
http://en.wikipedia.org/wiki/Tty
0
 
LVL 22

Accepted Solution

by:
pjedmond earned 500 total points
ID: 16923301
You will need to ensure that the script run by cron explicitly sets any constants required in your normal shell.

For example:

PATH, TOMCAT_HOME, any constants associated with whatever application or database you are using.

You will need to ensure any aliases used are set (or preferably not used at all for portabilities sake!)

Look at your environment variables, and check your .bash_profile, and ~/.bashrc for anything that you might have missed.

The tty is for the cron script to send text to. The easiest way to get around this is to redirect output to a log file:

./myscript.sh > /home/scripts/logs/scriptlog.log

HTH:)
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 16926028
Havent I mentioned about env variables?
Whatever...
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question