Script through cron and command line

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script through cron and command line
# 1  
Old 02-22-2008
Script through cron and command line

I have a script which runs fine through command line, but doesn't run through cron. There are some variables which are set by the .profile file which are used by the script. Is it that cront does not pick these variables.

$/export/home/rahul/bin/ >> /export/home/rahul/log/logfile.txt 2>&1

The above works fine and gives the output in the log as follows.
$cat /export/home/rahul/log/logfile.txt
File created.

When run through cron, the log file has the following output.
$cat /export/home/rahul/log/logfile.txt
sqlplus: Command not found.
sqlplus: Command not found.

Does the .profile not run for the user when the script is run through cron?

# 2  
Old 02-22-2008
this might help you
# 3  
Old 02-22-2008
sqlplus in cron job

Hi Rahul,
Whenever you use the sqlplus command in a cron job , you should give the entire path of the sqlplus command (Examle : <full path of oracle home>/sqlplus .....)

You can also give like this, $ORACLE_HOME/sqlplus .....

Rahul, i firmly belive the above given tip will solve your issue.

Last edited by apsprabhu; 02-22-2008 at 07:18 AM.. Reason: missed out
# 4  
Old 02-22-2008
it is always better source ".profile" in crontab as 'Yogesh Sawant' suggested. Sourcing will make sure all the environment variables required for your script is set.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command works at command line but not from cron

Oracle Linux 6. Trying to set up a simple monitoring of memory usage. This command does exactly what I want at the command line: echo $(date +%Y-%m-%d" "%H:%M:%S) $(grep PageTables /proc/meminfo) >> /home/oracle/meminfo.logBut when I put it in my crontab: * * * * * echo $(date +%Y-%m-%d"... (2 Replies)
Discussion started by: edstevens
2 Replies

2. Shell Programming and Scripting

Issue in running a command line utility in CRON

Hi Everyone! I am facing an issue in running a command line utility from the CRON. This utility displays IPC statistics on UNIX message queues: The "queue name" and the "count" of messages in the queue. When running this utility from prompt, it will provide an output on the screen, like the... (4 Replies)
Discussion started by: vai_sh
4 Replies

3. AIX

Commands to call script work from command line but not from Cron entry

My first post evidently did not materialize so I posted it again: Runnning a cron job every 5 mins to send data files to a state facility. My original cron entry at worked fine: 01,06,11,16,21,26,31,36,41,46,51,56 * * * * /home/sftpuser/stateinoc-from-appname.ksh Somewhere I have a... (1 Reply)
Discussion started by: Skyybugg
1 Replies

4. Shell Programming and Scripting

Script runs in command-line fine but times out in CRON?

Hi, I have a script that seems to run to completion when in the command-line, but when it is run using the cron, it seems to time out. They both start and run fine, but on the CRON it stops prematurely. The script hits an API every few seconds and grabs data. Does anyone have any idea on... (4 Replies)
Discussion started by: phpchick
4 Replies

5. Shell Programming and Scripting

How to check if script is run via cron or manual=command line?

Hi all, I have a script that can be run via cron or via the command line. Is there any way that I can place something on the script to be able to distinguish/differentiate whether the script was run via a user in the command line or whether it was run from the cron? (3 Replies)
Discussion started by: newbie_01
3 Replies

6. Shell Programming and Scripting

CRON shell script only runs correctly on command line

Hi, I'm new to these forums, and I'm hoping that someone can solve this problem... To make things short: I have DD-wrt set up on a router. I'm trying to run a script in CRON that fetches the daily password from my database using SSH. CRON is set like so(in web interface): * * * *... (4 Replies)
Discussion started by: louieaw
4 Replies

7. Shell Programming and Scripting

s3cmd works on command line not on cron

Ubuntu 9.10 is my linux distro Based on forums they say that the problem is with environment . here is my case: login as user, then sudo -s using this command: s3cmd put file s3://bucket >>worked! now here is the simple script intended for testing: #! /bin/bash env >/tmp/cronjob.log... (1 Reply)
Discussion started by: qwerty20
1 Replies

8. Shell Programming and Scripting

Cron job fails, but works fine from command line

I have a very basic script that essentially sends a log file, via FTP, to a backup server. My cron entry to run this every night is: 55 23 * * * /usr/bin/archive_logs The script runs perfectly when executed manually, and actually worked via cron for about three weeks. However, it mysteriously... (3 Replies)
Discussion started by: cdunavent
3 Replies

9. UNIX for Dummies Questions & Answers

script works on command line, not in cron job

Hey there, I'm a total newbie unix guy here and just picking this stuff up. Have a very small script I put together that works fine from the command line but not once I put it in a cron job. Searched and found this thread and am wondering it it has something to do with setting variables, though the... (7 Replies)
Discussion started by: JackTheTripper
7 Replies

10. UNIX for Advanced & Expert Users

process nice level command line vs cron

Under, Solaris 10 I have the following problem: A script executed at command line runs with nice level 0, as expected. Same script started under (user) crontab runs with nice level 2. I would prefer it run at 0. Is this possible? If so, how? Thanks. (0 Replies)
Discussion started by: henrydark
0 Replies
Login or Register to Ask a Question