Cron entry not running

Hi

I have one entry in my crontab that do not run, in cron, but it runs manually:

53 7 * * * /moneta_polled01/download/./get_dealer.sh
55 7 * * * /moneta_polled01/download/./mov_dealer.sh

The first entry do not run automatically, but it runs manually.
The second entry runs automatically.

What could be wrong?

It maybe because of the PATH variable not getting loaded.
Try giving the full paths to your commands instead of just the commds.Like, instead of just giving echo give

/bin/echo

Try giving the full path to all your commands

Sorry I dont understand, do you mean

/usr/bin/ftp

and

/usr/bin/cd

, and

/usr/bin/get

?

the script has the following:

#!/usr/bin/ksh

HOST=10.100.48.41
USER=ftp_fr
PASSWD=123456789

ftp -nv $HOST <<EOF
user $USER $PASSWD
cd Ordens
binary
get Shipment.csv
bye
EOF

Just give it for ftp . The rest are ftp commands.

did not work, I have changed to

/usr/bin/ftp -nv $HOST <<EOF

and change crontab entry time as well:

50 8 * * * /moneta_polled01/download/./get_dealer.sh

Check our FAQ:

How come it runs well on the second entry, but not the first one?

30 10 * * * /moneta_polled01/download/./get_dealer.sh
55 7 * * * /moneta_polled01/download/./mov_dealer.sh

Start by telling the differences between both of these scripts.

cd /moneta_polled01/download
ls -l get_dealer.sh mov_dealer.sh
diff get_dealer.sh mov_dealer.sh

You should also explain how you assert the first one doesn't run well. Any error message ? Did you check for mails ?

this is:

 ls -l get_dealer.sh mov_dealer.sh
-rwxrwxrwx   1 root     root         153 Apr 28 09:42 get_dealer.sh
-rwxrwxrwx   1 root     root         736 Apr 25 08:27 mov_dealer.sh

I know its not working because if I do a

ls -lrt

after the time set in cron, I do not have the file, but if run it manually

# pwd
/moneta_polled01/download
root@moneta # ls -lrt
total 4
-rwxrwxrwx   1 root     root         736 Apr 25 08:27 mov_dealer.sh
-rwxrwxrwx   1 root     root         153 Apr 28 09:42 get_dealer.sh
root@moneta # ./get_dealer.sh

I get the file.

It may be working. Just change the the directory to someplace you know and then do the ftp in your script. It may that the cron is placing the file someplace else. Do check the root directory or better try and run the find for the file that you want.

Hi

I did a

find / -type f -name Shipment.csv -print

and I found the file in

/

. But how come is there, because I am running it from

30 10 * * * /moneta_polled01/download/./get_dealer.sh

therefore from

/moneta_polled01/download

directory!!!

Its not "you" that run the script. Its the cron daemon that runs it. And the cwd of the cron daemon is the root directory, unless you change it in your script. In your script you are not changing the directory and hence the file is in /.

It doesnt matter where your script is, what matters is that where you are running the script from.

So better change the directory at the start of your script.

1 Like

Tnank you, its now working fine;)