Script is not executing as expected when I schedule it in cron
Hi,
I have a shell script which fetches the MRP status and the LAG status.
When I execute it manually like, sh <script_name>, it fetches the output as expected, but when I schedule through crontab, it's not working as expected.
Any help would be really appreciated.
Here is the code snippet:
The issue is, it's not getting into the line "status=`sqlplus -s "${pass} as sysdba" <<~EOF" at all, when I schedule it through cron, but manually it works.
Following is the sample output, when it's scheduled through crontab.
Please note that it's an AIX box.
Please help me out to get this rid of the weird situation and let me know if anything to be corrected in the script.
When I execute it manually like, sh <script_name>, it fetches the output as expected, but when I schedule through crontab, it's not working as expected.
Search this forum for "Cron Problem Number One" to find the one or other gazillion of threads dealing with this. The main problem is this line:
because: how should the system know where "sqlplus" is, without a PATH variable being set (which isn't set when executed from cron), hmm?
Quote:
Originally Posted by Nagaraj R
and let me know if anything to be corrected in the script.
Gladly so: first, get rid of the obnoxious backticks and use POSIX-means to do it:
Further advice might be given once you show us the complete script instead of a snippet. For a snippet of a script you only get a snippet of advice. ;-))
I hope this helps.
bakunin
Last edited by RudiC; 12-05-2016 at 08:07 AM..
Reason: Corrected /code tag.
The relevant part of /var/adm/cron/log may help.. it'll at least tell you if it's kicking off.
I've seen folks who source their profile before running a job, e.g.
I would recommend putting that all into its own script instead if muddying the crontab file with the literal contents of what you're trying to do due to the aforementioned environment and variable expansion issues.
Remember that cron does not "log in" so all of the nice stuff that works for an interactive login to a shell must be dealt with and setup explicitly
Hth
Last edited by rbatte1; 01-24-2017 at 08:11 AM..
Reason: Added CODE tags
Hello All,
I'm having an issue getting an expect script to run as a cron job. The script executes fin if I run it from the command line but I get nothing when trying to run it as a cron job. I've researched other forums and threads and there have been references to the environment, or lack... (16 Replies)
Hi,
I created a script which connects to database and update a table.
This script is running fine when i run it manually but when i am trying to execute it scheduling in crontab.script is executing but Data is not getting updated.
below is my script
sqlplus test/##### >> test_feed.log <<!... (6 Replies)
Hi Experts,
Iam bit poor in shell scripting,
Here my requirement is for generating an alert where the oracle database db_recovery_file_dest_size usage. If it reaches beyond 80% should recieve an alert through an email.
Want to schedule this alert in cron.
#!/bin/bash
.... (9 Replies)
Dear Experts,
Once again i need your vital help to fix my issue, please do the needfull.
Issue:- I have schedule one script on windows server to run's every 10 min.(Script do check the alert log file,if database found down it send the email) While i'm doing the database down manually its... (12 Replies)
Hi have a script which transferers from Microsoft server to Linux box.
The scripts(ksh) is on Linux box.
If I run script from terminal, it transfers files to directory. Where as If
I run script from CRON. It does not.
Here is the log of both:
Terminal execution log:... (2 Replies)
Hi,
I have a shell script as below:
ORACLE_HOME=/usr/local/opt/oracle/product/dev
export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin:/usr/bin
export PATH
OUTFILE=/export/home/`basename $0`.out
export OUTFILE
export IDEN
df -k . | tail -1 | read a b c d e f
echo $a >> $OUTFILE
echo $b... (4 Replies)
Status quo is, within a web application, which is coded completely in php (not by me, I dont know php), I have to fill out several fields, and execute it manually by clicking the "go" button in my browser, several times a day.
Thats because:
The script itself pulls data (textfiles) from a... (3 Replies)
The script checks for free space stats on Oracle. If there are any tablespaces with more than 85% usage it prints the details of the tablespace. If all the tablespaces have more than 15% free space, then "All tablespaces have more than 15 pct free space" must be printed on the screen.
When I run... (2 Replies)
Hi frnds...
I m facing very irritating problem already waisted my 2 days..
I have a following script..( i am pasting only the main code)
ftp -ivn 213.194.40.77 <<FTP
user $user $password
binary
cd $FileDir/out
lcd $localpath
get $file
rename $FileDir/out/$file $FileDir/tmp/$file... (1 Reply)
This isn't the usual problem that a shell script runs from the command line and not the cron. It's a little different.
Among other things, the shell scrip executes my .profile to set a bunch of variables. It then does an env to ensure that it ran OK.
There are echos in the shell script and... (2 Replies)