Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 247
  • Last Modified:

Why does it work on command line but no cron ?

This crontab entry works fine on command line but as i put it in cron it errors:
20060616 15:03:00 ##### Starting Process
20060616 15:03:00 ##### Exporting ORACLE_SID as IF9P1
20060616 15:03:00 ##### Obtaining Passwords
20060616 15:03:00 ##### ERROR  !! PLEASE INVESTIGATE !!!

Does cron have a different enviroment to command line
  • 3
1 Solution
> 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.
hraja77Author Commented:
what is TTY
TTY - text terminal
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:

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

Havent I mentioned about env variables?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now