A script doesnt work properly when crontab


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting A script doesnt work properly when crontab
# 8  
Old 04-13-2009
Quote:
Originally Posted by digitalrg
Thanks Choogendyk,
I placed #!/bin/bash, changed the `/path/to/script`, commented SCP and also i put in the return core it says " return code 2 "but no tar file has been created.. i dont know how to setup mail in Ubuntu... hep plz...
Just assign a value to the MAILTO environment variable in your crontab:

Code:
MAILTO=your.email@your.host
* * * * * command

# 9  
Old 04-13-2009
Quote:
Originally Posted by digitalrg
I placed #!/bin/bash, changed the `/path/to/script`, commented SCP and also i put in the return core it says " return code 2 "but no tar file has been created.. i dont know how to setup mail in Ubuntu...
You're saying when you ran the script off cron, it gave a return code of 2, but you don't know how to setup mail . . . So, how did you get the output with the return code?

Anyway, 2 is a fatal error. But it doesn't really tell us much. Are there no other errors in the output? Or are you not yet getting an email of the output? If not, do as ripat suggests with MAILTO in your crontab.

I assume you are using the same user account interactively as with crontab?

Did you comment out all three lines of your scp?

You might try doing a `set` at the beginning of the script (right after the #! line), so that you can see what your environment is and what the differences are between interactive and cron.

If you can't resolve it playing around with these ideas, you might want to post a simplified version (leaving out the commented stuff) and the messages it produces. Don't bother with all the `set` output, just check it for differences.
# 10  
Old 04-15-2009
Hi ALL,
I have resolved the issue by changing as below
cron settings to 01 11 * * 1-6 . /scripts/backup-script.sh > /scripts/rgklog3.txt
change is that " . / " and re-directing the o/p
then in the sctript #!/bin/sh and just tar no need of any /usr/bin .. nothing
and it started working and i followed another post on the same forum hot to exchange SCP public keys and that problem is also resolved...
Thank you very much all of u...
Regards,
Raghav
# 11  
Old 04-15-2009
deleted

Last edited by clx; 04-15-2009 at 05:11 AM.. Reason: resolved.
# 12  
Old 04-15-2009
Cool. Enterprising of you to look through the forums and find the public key stuff. I was going to suggest that, but thought we should resolve the other stuff first.

I don't think you need the ". /" syntax. Redirecting the output to a file has gotten you around the email issue, and using sh instead of bash may have helped somehow.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Having trouble getting my interactive perl script to work properly

So I'm making an interactive perl script, but I can't get it to work properly. I'm trying to make a script that tell the user to input either 'q' or 'Q' to terminate the program, or 'c' to continue it. If they input anything other than those three keys, it should prompt the user again and again... (5 Replies)
Discussion started by: Eric1
5 Replies

2. UNIX for Dummies Questions & Answers

[SOLVED] Mv command doesnt work in shell script

Hi All, i created the below script to move file with xml extension from one directory to another,but the mv command is not working inside the shell script, #!/us/bin/ksh filepath="/apps/extract" filename="*.xml" foldername=2191POB000_$(date +%Y%m%d%H%M%S) mkdir -p "$filepath/$foldername"... (3 Replies)
Discussion started by: Radhas
3 Replies

3. UNIX for Dummies Questions & Answers

why doesnt it work?

I am trying to print out two fields in a file using awk. So, I have got awk -F '\t' 'NF = 2 {print $1 $2 "]"}' two.txt in a script called what.awk When i run this version like this - ./what.awk then it runs however I want to run the program like this awk -f what.awk two.txt. When I... (8 Replies)
Discussion started by: The undertaker
8 Replies

4. AIX

Vi doesnt work

Hi Guys, I have a strange problem.( AIX 6.1) "vi" is not working at all..Whenever i #vi <anythin> ,, it returns the prompt back. Any clues folks?? (14 Replies)
Discussion started by: muzahed
14 Replies

5. Shell Programming and Scripting

Script not running properly when run from Crontab

Hi I am a novice Linux/Perl user and am struggling to overcome what I am sure is a simple problem. I am using a perl program to create a shell script daily containing between 10 and 30 "at -f" commands for the same day. Then I change the file attributes to allow the file to be executed. When... (2 Replies)
Discussion started by: simoncjones
2 Replies

6. AIX

Crontab file doesnt seem to work

Hi all. Could anyone explain me why this simple cron job doesnt work: % whoami system % crontab -l * * * * * /usr/bin/touch /home/system/foo (3 Replies)
Discussion started by: bsddaemon
3 Replies

7. UNIX for Dummies Questions & Answers

cp doesnt work - Help

When trying to copy a file in Solaris 8 it doesnt copy file or give a error. This worked 100% until the 29th. I've checked the rights and everything seems fine: drwxrwxrwx 2 bmuser bmgroup 11776 Jan 3 10:32 spool This is the file I want to copy: -rwxrwxrwx 1 bmuser bmgroup ... (26 Replies)
Discussion started by: rudi.okelly
26 Replies

8. Solaris

SSH doesnt exit properly from command line

I ssh to another server and run a few commands - start a few processes that run on the server. I then type exit - by my command line hangs. I have heard that it is waiting until anything processes you are running complete, but these processes are going to run 24*7*365 so obviously I cant wait.... (4 Replies)
Discussion started by: frustrated1
4 Replies

9. UNIX for Dummies Questions & Answers

cd.. doesnt work

hi when i want to go to previous directory by typing cd.. i get the following message $ cd.. ksh: cd..: not found Please help rintingtong (2 Replies)
Discussion started by: rintingtong
2 Replies

10. Shell Programming and Scripting

why doesnt my script work!!!

Is there a utility or command I can use to tell the number of decimal places a number has. For instance, if the number is 432, it will give hundred as the number of decimal places. (7 Replies)
Discussion started by: Heedunk
7 Replies
Login or Register to Ask a Question