Solved

Why does it work on command line but no cron ?

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
nagios remote hosts 9 56
nagios 4 php error after installation 6 95
Setting up static IP - Ubuntu server 16.04 12 65
Linux script delete files 3 34
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Fine Tune your automatic Updates for Ubuntu / Debian
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 get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

803 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