Do you get any errors? Running in 'cron' is not like logging in, more like running "ssh user@ost ksh". Your environment is not set up, so commands that work interactively or with a controlling terminal may not run. Usually, the script starts with something like ". ./.profile </dev/null >/dev/null 2>&1" to get environment, but if you need a tty, tougher, maybe "ssh -tt localhost ' ./.profile </dev/null >/dev/null 2>&1;cmd args ....".
Also, 'cron' can discard or email stdout and stderr, so redirect them right off in the crontab line, and maybe everything inside the script as well:
Be careful as '%' is meta in crontab, so it is hard to use date there. I wrote a 'date' wrapper that used '~' for '%', just for 'cron'. If the scripts that cron calls all immediately redirect their logging, you can use a shared log for all crontab lines that is fixed, as it is normally empty. Set up good logging. You deserve it. It is a great investment in your development speed (fast debug) and future (prod support much later).
Last edited by DGPickett; 03-06-2013 at 03:18 PM..
In addition to what DGPickett said, I would suggest to be explicit regarding the absolute path to the rman executable:
export the ORACLE_HOME variable and use "$ORACLE_HOME"/bin/rman instead of just rman.
On some Linux distributions, for example, you may have more than one executable file named rman
(you could have /usr/bin/X11/rman for instance).
Welcome to the land of ssh, cron and at. When you log in, you are given environment by layers of files. If a pid runs not logged in, it has to build environment. Full absolute paths are just a weak stopgap for a bigger symptom. What if you need a dynamic lib*.so and your LD_LIBRARY_PATH is unset? Oracle has its own env needs.
If you want something simple, you can just "set >.runtime_env" and clone your environment. Some of it may be too specific to your login to be appropriate; it will be 'too much'. I do 'if' sections in my .profile for 'only if tty present', 'only if X', 'only if ksh' or 'only if bash', so it prunes itself down in cron, sh, ssh.
Hi,
I have a bash script to run many system commands on CentOS machine, but I am puzzled by some commands had no effect on parent environment.
For example, I want to refresh the desktop xdg menu when some processes added or deleted items from desktop xdg menu. If I run "killall gnome-panel"... (4 Replies)
Hi,
I have the following RMAN incremental shell script:
# !/bin/bash
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=ORCL
export PATH=$PATH:${ORACLE_HOME}/bin
rman target=/ << EOF
run {
allocate channel d1 type disk FORMAT... (3 Replies)
Hi
I have a program
int main(int srgc, char *argv)
{
for(int i=1; i<50; i++)
{
system("dd if=/dev/zero of=file$i bs=1024 count=$i");
}
return 0;
}
My doubt is how to use the "$i" value inside C code
Please help (2 Replies)
I would like to execute a commands in four different servers through ssh at a single instance(simultaneously).
Below are the details with examples,
ssh user1@server1 "grep xxxx logs"
ssh user1@server2 "grep xxxx logs"
ssh user1@server3 "grep xxxx logs"
Each statement will take some... (4 Replies)
When my script deals with large input files like 22Gb or 18 GB the basic commands like sort or join fails when run from inside the shell scripts. Can there be any specific reason for this?
For e.g.
sort -u -t "," -k1,1 a.csv > a.csv.uniq"
sort -u -t "," -k1,1 b.csv > b.csv.uniq"
The... (3 Replies)
Dears,
I'm new in shell scripting and i need your help, i would like to know how can i create a script to ftp to a certain unix/linux machine/server IP address and get a file for example without user intervention? How can i force the script to use a certain username and password to access this... (4 Replies)
Hi,
I have an HTML form through which I get some text as input. i need to run a shell script say script.sh inside a perl-cgi script named main_cgi.sh on the form input.
I want to write the contents of the form in a file and then perform some command line operations like grep, cat on the text... (2 Replies)
Hi Experts,
Can anyone help me to write shell script for taking backup with RMAN in oracle 9i or suggests me any site which has this kind of scripts
Thanks
shaan (1 Reply)
Hi ,
I am having one situation in which I need to run some simple unix commands after doing "chroot" command in a shell script. Which in turn creates a new shell.
So scenario is that
- I need to have one shell script which is ran as a part of crontab
- in this shell script I need to do a... (2 Replies)