Solved

Why does it work on command line but no cron ?

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Bash script - Exit out of choice loop 2 53
PHP error function not working on AWS 10 117
Check for Linux process in script 7 65
WordPress: Debugging from my Windows 10 Desktop 6 61
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…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

679 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