Solved

Why does it work on command line but no cron ?

Posted on 2006-06-16
5
232 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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.

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now