?
Solved

Why does it work on command line but no cron ?

Posted on 2006-06-16
5
Medium Priority
?
243 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

718 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