Re: GPG in crontab causes blank messages



In article
<usenet.kadin-F01ECA.14471823082007@xxxxxxxxxxxxxxxxxxxxxxxx>,
Kadin2048 <usenet.kadin@xxxxxxxx> wrote:

I'm having a strange issue involving my crontab that's totally got me
stumped. When I run my crontab command manually in terminal, it works
fine; but when it actually runs on its own, it seems to fail.

Background: I use a couple of shell scripts to back up my Macs
~/Documents folders to a remote machine in the middle of the night.
Basically, I have it set up so that the script runs, and its output is
emailed to me via the CLI "mail" program. (I have postfix set up with a
smarthost on each machine so that this works.)

But since the output of the script contains a big list of files, I
decided to encrypt the script's output before sending it via plaintext
email. This seemed pretty simple -- I'll just pipe the output from the
script through GPG, and then pipe it into the mail program as usual to
email it.

Example crontab entry: (one long line)

30 1 * * * sh ~/bin/backup.sh 2>&1 | gpg -e -a -r myemail@xxxxxxx | mail
-s "[Auto] Daily Backup Report" myemail@xxxxxxx

When I take the command and run it manually, by just copying/pasting and
executing it in the Terminal, it works perfectly. What I get is the
output of the backup script, emailed to me as an ASCII-armored,
GPG-encrypted message. Exactly what I want.

However, when the thing runs at night, all I get in the morning is a
blank email message. If I remove the GPG portion of the command, it
works (I get a plaintext message with the script output).

I'm a little mystified as to why a command would work when typed
directly into Terminal, but would misbehave when in a crontab.

Has anyone ever run into anything like this before? Any suggestions or
obvious flaws in what I'm trying to do?

It looks like you don't have the environment for the crontab execution
set to include the path to gpg. Try either explicitly specifying the
path to gpg or including a PATH statement that specifys the path.

--
Tom Stiller

PGP fingerprint = 5108 DDB2 9761 EDE5 E7E3 7BDA 71ED 6496 99C0 C7CF
.



Relevant Pages

  • SUMMARY: cron entry: nth day of every month?
    ... cron can not handle this with its own syntax. ... 21st but "command" only runs if the output of the "date" command ... What I would suggest is rather than embedding the logic in each script ... The answer is it is _not_ possible to control it only with crontab ...
    (Tru64-UNIX-Managers)
  • Re: crontab issue
    ... your environment ... ... Simon is absolutely right about the script ... ... crontab file ugly, just because you can? ... solved by making the command a separate script. ...
    (AIX-L)
  • Re: crontab issue
    ... But if it works fine from a script, ... questions about crontab problems on this list, most of which could easily be ... solved by making the command a separate script. ... > and the command would not execute. ...
    (AIX-L)
  • Re: crontab related .. again
    ... >>> The above command works fine with the following ... >>> This latter script work in command line. ... > Yes crontab allow */1 specificatin. ... > How to know the cron's working directory how to make the current ...
    (comp.unix.shell)
  • Simple expect script has erratic behavior, why?
    ... I have a simple expect script to decrypt a gpg file when passed the ... passphrase on the command line. ... If I run the gpg command from the command line, ...
    (comp.lang.tcl)