Home » Infrastructure » Unix » Problem in Crontab
Problem in Crontab [message #200712] Wed, 01 November 2006 01:05 Go to next message
oracledba_raja
Messages: 23
Registered: July 2006
Junior Member
Hi All,
Good Afternoon.
I have a script combinedprocess.sh.
Which in turn, calls another 2 shell programs process1.sh, process2.sh
When I am manually execute the file, it works fine.

Then, I have scheduled the shell script combinedprocess.sh in crontab.
It didnít give any output all.

I need your help.

=================================================================

/lms/billing =>cat combinedprocess.sh
#!/bin/sh
sh process1.sh
sh process2.sh

================================================================

Entry in Crontab

00 09 * * * /lms/billing/combinedprocess.sh

================================================================

File permission:
-rwxrwxrwx 1 lmsuser lms 46 Oct 31 17:57 combinedprocess.sh

-rwxr-xr-x 1 lmsuser lms 998 Oct 31 17:38 process1.sh
-rwxr-xr-x 1 lmsuser lms 995 Oct 31 17:38 process2.sh


Thanks and Regards,
Raja
Re: Problem in Crontab [message #200851 is a reply to message #200712] Wed, 01 November 2006 11:26 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10672
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
In crontab, you need redirect the output to elsewhere. Something Like this
0 6 * * * /home/oracle/scr/app/reminder >/tmp/reminder 2>&1

And

Quote:
#!/bin/sh
sh process1.sh
sh process2.sh


when this is executed from crontab, how do you expect CRON to see those files?
provide full path to the file (or export YOURFULLPATH and export $PATH:$PATH:$YOURFULLPATH)
Re: Problem in Crontab [message #200856 is a reply to message #200851] Wed, 01 November 2006 12:12 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
if you have a bunch of environment settings, you can also specify the environment profile either in crontab - or just at the top of your main script.
0 6 * * * . ~/cron_env; /home/oracle/scr/app/reminder >/tmp/reminder 2>&1

Re: Problem in Crontab [message #200857 is a reply to message #200856] Wed, 01 November 2006 12:21 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10672
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
Thanks Andrew.
That tip would be handy for me.
Re: Problem in Crontab [message #200988 is a reply to message #200712] Thu, 02 November 2006 02:47 Go to previous messageGo to next message
oracledba_raja
Messages: 23
Registered: July 2006
Junior Member
Hi Mahaesh & Andrew,
Thanks for your response.

I have given the full path the 'combinedprocess.sh'

/lms/billing/process1.sh
/lms/billing/process2.sh

and it works fine.

Thanks a lot.

One more doubt...

Can't we use 'cp' & 'mv' commands inside a script?

I just gave 'cp' as follows, in a shell as part of it.

#!/bin/ksh
cp disk3/ipp/outbound/prod/history/history.txt disk3/ipp/outbound/prod/historybackup

Other than this, all other things are working fine.

How to overcome this?
Could you please guid me.

Thanka a lot.

Thanks and Regards,
Raja
Re: Problem in Crontab [message #201007 is a reply to message #200988] Thu, 02 November 2006 04:11 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10672
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
May be it is a typo.
Quote:
disk3/ipp/outbound/prod/history/history.txt

Should'nt you use /disk3/..... ?
Re: Problem in Crontab [message #201009 is a reply to message #200712] Thu, 02 November 2006 04:16 Go to previous messageGo to next message
oracledba_raja
Messages: 23
Registered: July 2006
Junior Member
Hi,
Actually it is,
/disk3/ipp/outbound/prod/history/history.txt

When typed here, "/" was missing.

Thanks.

Raja.
Re: Problem in Crontab [message #201121 is a reply to message #201009] Thu, 02 November 2006 11:34 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
You can use virtually any command you want in crontab - you just need to be sure to set up all your environment variables. Run "env" to show your current environment, pick out the ones you need and put them into the top of your script - or source the environment file like I showed (cron_env).

#find where cp is
Dev1>>which cp
#find where mv is
Dev1>>which mv
/usr/bin/mv
Dev1>>which ping
/usr/sbin/ping


e.g.
----- cron_env ----
export PATH=/usr/bin:/usr/sbin:/users/home/myscripts:.
export LOG=/tmp/mylog.txt
Re: Problem in Crontab [message #201186 is a reply to message #200712] Thu, 02 November 2006 22:42 Go to previous message
oracledba_raja
Messages: 23
Registered: July 2006
Junior Member
Hi Andrew,
Thanks a lot.

In the env file, I found

_=/usr/xpg4/bin/env
HOME=/disk3/ses/inbound/prod/bin
SHELL=/usr/bin/ksh
PWD=/disk3/ses/inbound/prod/bin

It has been set by my predecessor in my present company.

He also set some jobs in crontab,

#00 10 * * * /disk3/ses/inbound/prod/bin/dof 1>> /disk3/ses/inbound/prod/log/pdx-neg.cron.log 2>> /disk3/ses/inbound/prod/log/pdx-neg.cron.errors

#10 10 * * * /disk3/ses/inbound/prod/bin/uf 1>> /disk3/ses/inbound/prod/log/pdx-neg.cron.log 2>> /disk3/ses/inbound/prod/log/pdx-neg.cron.errors


Now, I am working in different directory and that is

/disk3/ipp/outbound/prod/bin

but for logging still using his id.
As I am using his id, when I logged in I am in his directory
=/disk3/ses/inbound/prod/bin.

Then I use to change to my working directory.

Now, I have scheduled a job in a crontab.

45 10 * * * /disk3/ipp/outbound/prod/bin/renamefiles.sh >> /disk3/ipp/outbound/prod/bin/batchjob.log

The executable files are in
/disk3/ipp/outbound/prod/bin and it's subdirecotry.

Now, I found, the output of the crontab,
writes in his directory ..ie) in

/disk3/ses/inbound/prod/bin


I won't be allowed to change any settings, set by him.

As a part of crontab, the files are executing from my directory.
/disk3/ipp/outbound/prod/bin

The problem is,
As I said earlier, the output file has been written to his directory '/disk3/ses/inbound/prod/bin'

How to make the files to be written to my directory?
As I am not allowed to change the settings,
How I can specify the settings in my codings to get desired output?

I am very sorry.. My question may sound stupid..

Could you please guide me...

Thanks for your time to go thru this lengthy mail.

Thanks a lot.

Thanks,
Raja



Previous Topic: how to manage errors in unix's scripts for the oracle's connections and procedures calls
Next Topic: Installation on Solaris
Goto Forum:
  


Current Time: Sat Dec 10 03:09:45 CST 2016

Total time taken to generate the page: 0.05821 seconds