[CentOS] gpg command works fine from login shell, not from cron script

Bill Campbell

centos at celestial.com
Mon Oct 19 19:45:37 UTC 2009


On Mon, Oct 19, 2009, Sean Carolan wrote:
>I have an odd situation here, maybe one of you can help.  We have a
>script that runs via a cron job.  It's purpose is to decrypt
>PGP-encrypted files in a certain directory.  I have tried the command
>two different ways, both fail with the same error message:

Typically this type of problem is caused by environment variables
that are set in a login shell, but are missing or different than
those set for jobs running under cron.

A relatively simple way of finding the differences in the
environment is to use the ``env'' command.  In the shell, execute
the command ``env | sort > /tmp/env.shell''.  Then create a
simple script and run it under cron:

#!/bin/bash # (or whatever you run as a shell)
env | sort > /tmp/env.cron
exit.

Use ``diff -u /tmp/env.shell /tmp/env.cron'' to see the
differences.

Bill
-- 
INTERNET:   bill at celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
Voice:          (206) 236-1676  Mercer Island, WA 98040-0820
Fax:            (206) 232-9186  Skype: jwccsllc (206) 855-5792

When I hear a man applauded by the mob I always feel a pang of pity
for him.  All he has to do to be hissed is to live long enough.
    -- H.L. Mencken, Minority Report



More information about the CentOS mailing list