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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for you quick and correct response! Worked like a charm!
what is pwd whe you run it, and what is pwd when cron runs it?