Crontab assistance


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Crontab assistance
# 1  
Old 08-25-2010
Crontab assistance

I have a script that runs a SQL query and then emails me the results. It runs correctly alone. I am trying to set up a cron that will run the script every day at say 5:00. When the script runs alone, the results are emailed exactly like I want the, but when I set up a cronjob, I get a blank email. with the subject indicated in the script.
The script is owned by the correct user and the cron is set in the users crontab. I accessed it my using crontab -e. Is there any reason the cron would cause the script to not email me the same results as just running the script alone??
Thanks!
# 2  
Old 08-25-2010
be sure to use the full path for any commands you are using. The users profile is not loaded when cron is run so if you stored any variables in there it would not be set at run time.
# 3  
Old 08-25-2010
Excuse my ignorance, I am very noob!
Here is my cron.

Code:
10 15 * * * /u01/prod/prodcomn/admin/scripts/specialrequests/icat_request/icat_export.sh PROD

So are you saying I perhaps need to add my user at the start of the cron?

Code:
10 15 * * * applprod /u01/prod/prodcomn/admin/scripts/specialrequests/icat_request/icat_export.sh PROD

applprod is obviously my user.

Thanks so much!
# 4  
Old 08-25-2010
We're talking about paths inside your script, not in the crontab file. The PATH given by cron is very minimal and may not use all the commands you use if any are outside of the very basic /bin/ and so forth.
# 5  
Old 08-26-2010
Is your script giving any output? If yes and that output is not required, redirect that to /dev/null.

Make sure you are not using any server global variables in the script. They won't be available untill someone logs in.
# 6  
Old 08-26-2010
Load your .profile into the script at the beginning.

Such as this:

HOME=/dst/home/nikudev # This should be the location of your .profile file
export HOME

. $HOME/.profile
# 7  
Old 08-26-2010
Thank you for the responces. Here is my script. The script works and the result is a SQL query being emailed to me. I DO need that result.

Code:
    SID=$1
  DIR=/u01/prod/prodcomn/admin/scripts/specialrequests/export_icat.sql
  ORACLE_SID=$SID; export ORACLE_SID
  PATH=$ORACLE_HOME/bin:$PATH; export PATH
  cd $DIR
  sqlplus user/pwd @export_icat.sql > export_icat.csv
  mail -s "Results" email@domain < export_icat.csv
  mv export_icat.csv "`date +%m%d%Y`_export_icat.csv

export_icat is the sql query that is called to run by the script. The result of the query is saved to export_icat.csv. That file is then emailed to me.

So I should be indicating my user profile at the start of my script?
Thanks!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed assistance

Hello everyone. I am trying to replace sprintf(buffer, "{\"id\":1,\"method\":\"mining.update_block\",\"params\":}\n", coinid, blockhash); with sprintf(buffer, "{\"id\":1,\"method\":\"mining.update_block\",\"params\":}\n", coinid, blockhash); this is the code I was trying but is... (9 Replies)
Discussion started by: crombiecrunch
9 Replies

2. Shell Programming and Scripting

Need assistance with looping

Hi, I have a find command that searches for all the .properties under current directory and its subdirectories. find . -name "*.properties" I would like to pass the output of the above find command to my "operation.sh script as the second parameter. for eg: ./operation.sh 775 ... (2 Replies)
Discussion started by: mohtashims
2 Replies

3. AIX

AIX 3.2.5 Assistance

I am looking for any help on locating a set of install disks or downloads of AIX 3.2.5 or earlier.. We recently lost our HDD running AIX 3.2.5 and need to reinstall but have no OS disk to complete.. Any help would be appreciated.. Thanks (4 Replies)
Discussion started by: rmsdp
4 Replies

4. Shell Programming and Scripting

Need assistance with sed

Hi All, I need your assistance, I would like to replace all lines beginning with the word "begin" with the below text: Device | IPMB0-A | IPMB0-B Board Address |Sent SentErr %Errr |Sent SentErr ... (9 Replies)
Discussion started by: Dendany83
9 Replies

5. UNIX for Dummies Questions & Answers

awk o/p assistance

Hi, I would like to know the awk command that gets the below o/p: File contents: Board1;9a;60;36;60.0;60;0;0.0 Board2;96;60;35;58.3;55;0;0.0 Board3;92;60;60;100.0;60;60;100.0 Used awk script: #!/bin/awk -f BEGIN { FS = ";"; printf (" Device | ... (1 Reply)
Discussion started by: Dendany83
1 Replies

6. Homework & Coursework Questions

Assistance on work

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Files stored in /bin, /sbin, /usr/bin, and /usr/sbin vary in their respective sizes. In fact, there are 244... (1 Reply)
Discussion started by: alindner
1 Replies

7. Shell Programming and Scripting

Awk Assistance

Hello A friend of mine posted this on another site that I follow. It is to advanced for me to figure out. If solved I will give credit where credit is due: NOTE: Does not have to be AWK. Any Language will work, Hi. I need a little assistant to write an awk script on linux that reads a file... (12 Replies)
Discussion started by: abacus
12 Replies

8. Shell Programming and Scripting

An urgent assistance

Hi. Does any one know when the below will print hi ? || echo hi Thanks in advance (5 Replies)
Discussion started by: kinny
5 Replies

9. Shell Programming and Scripting

I need an assistance

I have a school project to create a shell program same as calendar i must create a txt file with celebrations with vi i know this but the problem is i don't know awk and grep. The object of object is to create a program who read a date an appear the celebration. Can you help me please !!!... (1 Reply)
Discussion started by: mytilini boy
1 Replies

10. UNIX for Dummies Questions & Answers

Need Assistance

I have two questions I am struggling with... How do the programs p1, p2, and p3 need to handle their standard files so they can work like this: p1 | p2 | p3 ? What exactly is this command supposed to do? $ kill -QUIT %1 & This command below? $ sort -o emp.lst emp lst & Any... (1 Reply)
Discussion started by: yahoo14
1 Replies
Login or Register to Ask a Question