Not working when running as a cron job

Started by paul30003, December 23, 2016, 05:29:35 PM

Previous topic - Next topic

paul30003

Hi,

I've created a script to add exif data to an image.  I extract filemodifydate and process it with Imagemagick it works as expected when run from terminal, however if I run the same script as a cron job, I get no exif data.

I have been doing a little debugging,


DATETIME=$(exiftool -filemodifydate $SRCDIR/${fnames[$i]}) #Assign jpg modified date to $DATETIME

echo ${DATETIME:36:17}>>$DEST/log.txt #For debugging to check if DATETIME gets a value!

convert $SRCDIR/${fnames[$i]} -font Helvetica -pointsize 20 -draw "fill white  text 10,470 '${DATETIME:36:17}' " $DEST/${fnames[$i]}


when run from the command line, log.txt gets updated.  From a cron job.  Nothing!

Much googling and code modification yields no results, so I've landed here to ask for help. What am I missing.

Many thanks.

Paul

StarGeek

Is exiftool in the path that cron can use?  Maybe explicitly set the path to exiftool in cron job to see if that's the problem.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

paul30003

Quote from: StarGeek on December 23, 2016, 05:33:48 PM
Is exiftool in the path that cron can use?  Maybe explicitly set the path to exiftool in cron job to see if that's the problem.

Yep,

Thats fixed.

I changed my script as follows.


DATETIME=$(/usr/local/bin/exiftool -filemodifydate $SRCDIR/${fnames[$i]})

echo ${DATETIME:36:17}>>$DEST/log.txt

convert $SRCDIR/${fnames[$i]} -font Helvetica -pointsize 20 -draw "fill white  text 10,470 '${DATETIME:36:17}' " $DEST/${fnames[$i]}


Works as expected.

Thanks for your help.

Paul