ImageMagick: weird issue when called by a cron job

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
fablau
Posts: 7
Joined: 2012-01-23T17:53:40-07:00
Authentication code: 8675308

ImageMagick: weird issue when called by a cron job

Post by fablau »

Hello here,
I am experiencing a weird issue with ImageMagick (vesion 6.7.4-4), in particular with the "convert" command.

While I am logged as root, I am able to make the following simple conversion without any reported error:

Code: Select all

/usr/local/bin/convert source.pdf destination.gif
If I call the exact same command from a cron job run by root, I get the following error:

Code: Select all

sh: gs: command not found
convert: Postscript delegate failed `/my-path-to/source.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/667.
convert: missing an image filename `/my-path-to/destination.gif' @ error/convert.c/ConvertImageCommand/3016.

Any ideas? This is really weird... I mean, if I run the command via shell manually as root it works just fine, but if I call it as a cron job as root it doesn't...

Any suggestions and thoughts are very welcome!

Thank you.

All the best,
Fab.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageMagick: weird issue when called by a cron job

Post by fmw42 »

perhaps it is a permissions issue on the file gs or gsc. locate that file (probably /usr/local/bin) and check to see if

-rwxr-xr-x 1 root admin 9240 Nov 30 14:54 gsc
fablau
Posts: 7
Joined: 2012-01-23T17:53:40-07:00
Authentication code: 8675308

Re: ImageMagick: weird issue when called by a cron job

Post by fablau »

Thank you for your reply, but permissions look correct:

-rwxr-xr-x 1 root root 16377359 Jan 5 15:43 gs

Any more thoughts?
fablau
Posts: 7
Joined: 2012-01-23T17:53:40-07:00
Authentication code: 8675308

Re: ImageMagick: weird issue when called by a cron job

Post by fablau »

Problem solved: I added the following command before invoking convert:

export PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin;

and now it works just fine. It is weird though that despite I am invoking "convert" from a cron job acting as the same exact user I am using manually (root) is not finding the path to look into for calling "gs" (which is inside the /usr/local/bin dir).

Thank you anyway for your help.

Best,
Fab.
Post Reply