crontab issue

Helo .
I have 2.6.13-1.1526_FC4smp here.
I am trying to make crontab execute my simple shell script, but noting happens.

here is how i am testing this :

[oracle@dell ~]$ pwd
/home/oracle
[oracle@dell ~]$ ls -l two*
ls: two*: No such file or directory
[oracle@dell ~]$
[oracle@dell ~]$ crontab -e
crontab: installing new crontab
[oracle@dell ~]$
[oracle@dell ~]$ crontab -l
30 16 * * 4  /home/oracle/go.sh
[oracle@dell ~]$
[oracle@dell ~]$
[oracle@dell ~]$ cat go.sh
one.txt > two.txt
[oracle@dell ~]$
[oracle@dell ~]$
[oracle@dell ~]$ cat one.txt
blabla
[oracle@dell ~]$
[oracle@dell ~]$ date
Thu Oct 29 16:26:58 CET 2009
[oracle@dell ~]$
[oracle@dell ~]$ ls -l two*
ls: two*: No such file or directory
[oracle@dell ~]$
[oracle@dell ~]$
[oracle@dell ~]$ ps -ef | grep cron
root      2494     1  0 Oct16 ?        00:00:00 crond
oracle   27977 26405  0 16:27 pts/0    00:00:00 grep cron
[oracle@dell ~]$
[oracle@dell ~]$
[oracle@dell ~]$ date
Thu Oct 29 16:32:10 CET 2009
[oracle@dell ~]$
[oracle@dell ~]$ ls -l two*
ls: two*: No such file or directory

I can't understand why this go.sh can't be executed. What am i doing wrong ?
Am i missing some permisions or what?
Thanks...

First: in your script, there's no shebang line, so the system won't know which interpreter to run it in
Second: in your script, you're trying to run a text file. If you want to just output the contents to a new file, use either cp or cat
Third: did you check the mails for user oracle? cron by default reports all output and error messages via mail to the user.
Fourth: is the executable bit set on your "script"?

Many issues here.
1) What are the permissions of go.sh and the rest of the files mentioned?

cd /home/oracle
ls -lad go.sh
ls -ald one.txt
ls -lad two.txt

2) The contents of "go.sh" make no sense and will give errors. It tries to execute a command called one.txt and put any output to STDOUT to file two.txt .
What is the script meant to do?

3) The error messages should be in unix mail for account oracle.

by shebang he means specify the shell in the first line of go.sh, such as
#!/bin/ksh
or else in your crontab line specify the shell: ksh go.sh
if you want to redirect the contents of a text file, just use the "cat" command:
cat one.txt > two.txt

Thank you all for your answers.
I did some modifications as per your suggestions, but the results are still negative.
Script still don't do what it should.

[oracle@dell ~]$ cat go.sh
#!/bin/bash
cp /home/oracle/one.txt /home/oracle/two.txt
[oracle@dell ~]$
[oracle@dell ~]$
[oracle@dell ~]$ crontab -l
46 8 * * 5  /home/oracle/go.sh
[oracle@dell ~]$
[oracle@dell ~]$
[oracle@dell ~]$ date
Fri Oct 30 08:43:57 CET 2009
[oracle@dell ~]$
[oracle@dell ~]$ ls -lad go.sh
-rw-r--r--  1 oracle oinstall 57 Oct 30 08:43 go.sh
[oracle@dell ~]$ ls -ald one.txt
-rw-r--r--  1 oracle oinstall 7 Oct 29 16:17 one.txt
[oracle@dell ~]$ ls -lad two.txt
ls: two.txt: No such file or directory
[oracle@dell ~]$
[oracle@dell ~]$ date
Fri Oct 30 08:53:40 CET 2009
[oracle@dell ~]$
[oracle@dell ~]$
[oracle@dell ~]$ ls -l *.txt
-rw-r--r--  1 oracle oinstall    7 Oct 29 16:17 one.txt
[oracle@dell ~]$ ps -ef | grep cron
root      2494     1  0 Oct16 ?        00:00:00 crond
oracle    5877 26405  0 08:55 pts/0    00:00:00 grep cron
[oracle@dell ~]$

can you please point me in the right direction ?
What did i missed here ?

Your problem is right here:

[oracle@dell ~]$ ls -lad go.sh
-rw-r--r--  1 oracle oinstall 57 Oct 30 08:43 go.sh

No executable bit set. Add that with chmod, and everything should be fine.

Thanks pludi , you are correct.
After i did chmod(744) , cp command created new file ,'two.txt' at the time it was specified in the crontab.

Glad you got it solved. Another angle you could have worked would be to run the script manually for your troubleshooting before scheduling in crontab. Always manually test before scheduling :slight_smile:

To help debug your script:
Try adding 'set -x' as the second line of your script and see what happens when you run it. An alternative, if you do not want to modify the script, would be to run 'bash -x /home/oracle.go.sh' or 'pdksh -x /home/oracle/go.sh'. This will give you some good debug output for any error conditions that may exist.