LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-08-2015, 09:26 AM   #16
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947

The @ goes at the beginning of the line...

I thought you wrote this script? Are you even looking at the errors you're seeing?
 
Old 02-08-2015, 12:07 PM   #17
azheruddin
Member
 
Registered: Dec 2011
Posts: 77
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
can anyone assist here/
 
Old 02-09-2015, 02:27 AM   #18
azheruddin
Member
 
Registered: Dec 2011
Posts: 77
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
Hi suicidaleggroll,
Can you please have a look error, changes been done in script as suggested.
 
Old 02-09-2015, 04:23 AM   #19
unimatrixdoc
LQ Newbie
 
Registered: May 2012
Location: OR
Distribution: Ubuntu
Posts: 4

Rep: Reputation: Disabled
KISS

It's a rough sketch, but maybe this will be of some help.
Not sure if it will work so please test safely.

There are three files to modify/create:
(1) /etc/crontab
(2) /home/oracle/my_cron_script.bash
(3) /home/oracle/my_cron.sql
(4) /home/oracle/my_cron_script.log

The fourth is a log file produced by the my_cron_script.bash

-unimatrixdoc

#########################################
# FILENAME: /etc/crontab
#########################################
Code:
# Man page for crontab:
# http://ss64.com/bash/crontab.html
# recommend using a user crontab!

# replace user_name with correct user that has rights
06 0 * * * user_name bash /home/oracle/my_cron_script.bash > /home/oracle/my_cron_script.log
#########################################
# FILENAME: /home/oracle/my_cron_script.bash
#########################################
Code:
#!/bin/bash

# Basic info about the ORACLE_HOME environment varible can be found here:
# http://docs.oracle.com/cd/E11882_01/server.112/e16604/qstart.htm#i1055567
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/client_1

# Are you trying to run SILENT? it's capital -S
# http://docs.oracle.com/cd/B19306_01/server.102/b14357/ch3.htm#i1169374
/home/oracle/app/oracle/product/11.2.0/client_1/bin/sqlplus -S /nolog < /home/oracle/my_cron.sql

# sql file syntax can be found here:
# http://ss64.com/ora/syntax-sqlplus.html

# Info about /nolog
# http://docs.oracle.com/cd/B19306_01/server.102/b14357/ch3.htm#sthref628
#########################################
# FILENAME: /home/oracle/my_cron.sql
# NOTE: put a fullpath to
# extract_data.sql location
#########################################

Code:
CONNECT user/user_1234@CBDTEST
@extract_data.sql
 
Old 10-30-2015, 01:46 PM   #20
MiraiKuma
LQ Newbie
 
Registered: Oct 2015
Posts: 1

Rep: Reputation: Disabled
Fix

I ran into this today. Using a couple of links around the internet I found the solution to be as follows:

Edit your crontab so it looks like this:

SHELL=/bin/bash
*/15 * * * * . /home/HomeFolder/.profile; cd /directory/of/your/script; ./runScript.sh > /dev null 2>&1

Please note the . before the full path to your profile. This for me worked while everything else did not. What is happening is bash does not run in an environment by default. So as you have tried and failed (as did I) you have to setup your environment variables manually. I could not get mine to work right either with sqlplus so I used this. It declares that you run all cronjobs in a bash environment, it sources your .profile, changes the directory to the directory of your script, then runs your script.

You may not need to cd like I did. I have some other scripts that need to be called from the same directory. Can't hurt anything by using the cd command.

Hope this helps.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Crontab script not executing certain lines mkvakic Linux - Newbie 2 01-14-2013 05:33 AM
[SOLVED] script in called by crontab executing but not writing data to file. Dafydd Programming 2 08-02-2012 02:35 AM
[SOLVED] Crontab not executing specific script abdoullah Linux - General 3 06-17-2011 03:15 PM
Seems crontab is not executing script... jonaskellens Linux - Newbie 3 11-18-2010 09:20 AM
Executing PHP script in crontab (include path problems) bar338 Linux - Newbie 5 12-21-2009 03:36 PM


All times are GMT -5. The time now is 10:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration