Link to home
Start Free TrialLog in
Avatar of ctoolz
ctoolz

asked on

Bash script does not work as a cron job

Greetings,

I have a script that runs and converts some images using ImageMagic's convert utility. If you run it in the directory it does what it's supposed to, but when you execute the script as a cron job, it can't find the directories.

I am sure it has something to do with the very first line, but even if I hard code the directory on that line prior to the *.jpg, it comes back and says it can't find the file in the directory.

So again, when I load the sript below in the directory, it runs fine, when I run it with cron, I get this error message:

ls: cannot access *.jpg: No such file or directory

for img in `ls *.jpg`
do
convert -size 140x100 -resize 140x100 +profile '*' -shave 0x04 $img /home/realtordata/images/imagedownload/testthumbs/$img
 
done

Open in new window

Avatar of ozo
ozo
Flag of United States of America image

how did you hard code the directory on that line prior to the *.jpg?
what is pwd whe you run it, and what is pwd when cron runs it?
ASKER CERTIFIED SOLUTION
Avatar of amit_g
amit_g
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ctoolz
ctoolz

ASKER

Thanks for you quick and correct response! Worked like a charm!