cron job: command not found


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cron job: command not found
# 1  
Old 06-24-2010
Question cron job: command not found

Hi, I have a simple script. When I run it as cron job. I jot email saying:

/bin/sh: line 1: test.tmp: command not found.

the test.tmp looks like:
#!/bin/sh
date > done

Even I took first line out, I got the same error.
The current shell I have is /bin/tcsh

Could anyone help me out?
Thanks a lot!!
# 2  
Old 06-24-2010
Hi.

Consider that when you login to a server, you have a "context". The context is that your .profile, .bash_profile, or whatever, is executed for you.

Your current directory at this time will most likely be your home directory. The paths to all the commands you love to use, and the aliases you use will be set.

When you run a command with cron, the chances are that most of this doesn't happen.

Some good reading on the subject is provided in this link.
# 3  
Old 06-24-2010
On the off chance. Did you edit the script using unix "vi" (good) or something else such as Windows notepad (bad)?
Failing that, please state which Operating System and version you have and post the crontab entry.
You may find that creating a cron containing only and "env" command is informative because it will demonstrate the skeleton environment of cron.

On reflection the error message suggests that you need to specify the full path to your script in the crontab line.

Last edited by methyl; 06-24-2010 at 06:30 PM.. Reason: ... on reflection
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cron job cannot run the command

Hi, I created this cron job for asterisk to send sms daily to a number #!/bin/sh #custom mod - send sms once a day, at 07:00. CRON_PATH="/etc/asterisk/gw/crontabs_root"; if ! grep 'gsm send sms' $CRON_PATH > /dev/null 2>&1 ;then echo "* 7 * * * asterisk -rx 'gsm send sms 1 7666... (4 Replies)
Discussion started by: jazzyzha
4 Replies

2. Shell Programming and Scripting

UNIX command for checking the cron job failures?

Hi- I need to set a mail trap for checking the cron job filures in a server. I have many cron jobs running in our server. What unix command will identify the failed cron jobs? Your thoughts please!!!!! (6 Replies)
Discussion started by: ChandruBala73
6 Replies

3. Shell Programming and Scripting

Cron Job - date command problem

Hi I have one problem with cron job in Control Panel. I have a log file that is created once a day on another server and I need to transfer it in an exact time to my server so I wrote the cron job for it BUT the problem is in the date command: /filelog-`date +%Y-%m-%d`.tar.gz; The file... (1 Reply)
Discussion started by: bobo_balde
1 Replies

4. Shell Programming and Scripting

Problem with sar command in cron job

HI, I have a problem with 'sar' command. I am using the sar comman in script.when i execute the script manually using ./filenae, i am getting the desired output. But when i put the script in cron job i am not getting the desired value. Below is the script.. sar > $_LOCATION/sar.txt... (2 Replies)
Discussion started by: ahamed
2 Replies

5. UNIX for Dummies Questions & Answers

Cron job to run a command from another dir?

I would like to setup a cron job to run a command from another directory. What is the best way to do this? The cron file is in a directory and the script I want it to run is in another directory. I tried doing this in the cron file: /location/of/command/run.sh But that did not work.... (2 Replies)
Discussion started by: Sepia
2 Replies

6. Shell Programming and Scripting

Sudo command not working with cron job.

Hello, I have written a script that has a sudo command to change file permissions within it. When I run the script manually, the sudo command inside of it works fine. When the script is run through crontab I get the error "cron: not found". It the same user profile that I am using... (6 Replies)
Discussion started by: WhotheWhat
6 Replies

7. UNIX for Dummies Questions & Answers

bash: cron-config: command not found - PLEASE HELP ME!!

Hello All, I have installed Cygwin on Windows XP and working with some Shell scripting work, I have needed to schedule my script using the cornetab and whatever commands such as "cron", "cron-config" are not working in my cygwin shell, I re-installed the Cygwin but the same problem is with... (2 Replies)
Discussion started by: sriya
2 Replies

8. SuSE

inconsistent ls command display at the command prompt & running as a cron job

Sir, I using the following commands in a file (part of a bigger script): #!/bin/bash cd /opt/oracle/bin ls -lt | tail -1 | awk '{print $6}' >> /tmp/ramb.out If I run this from the command prompt the result is: 2007-05-16 if I run it as a cron job then... (5 Replies)
Discussion started by: rajranibl
5 Replies

9. UNIX for Dummies Questions & Answers

script works on command line, not in cron job

Hey there, I'm a total newbie unix guy here and just picking this stuff up. Have a very small script I put together that works fine from the command line but not once I put it in a cron job. Searched and found this thread and am wondering it it has something to do with setting variables, though the... (7 Replies)
Discussion started by: JackTheTripper
7 Replies

10. UNIX for Dummies Questions & Answers

cron command not found

I'm trying to execute a command in my crontab, but every hour I'm sent mail that says /bin/bash: root: command not found Does anyone know why I'm getting that message? It was in the crontab before I started screwing around with it and it was working fine. Now that I messed with it, ran a... (4 Replies)
Discussion started by: sstevens
4 Replies
Login or Register to Ask a Question