Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following script:

#!/bin/sh -e
echo before
echo $PWD | gpg --passphrase-fd 0 -c $file
echo after

The scripts works perfectly fine if executed manually, but simply stops working when the gpg line is performed when performed as crontab.

GPG shows:

gpg: cannot open `/dev/tty': No such device or address

I'm grateful for any suggestions!

Solution: add --no-tty to GPG

share|improve this question
$PWD is very bad choice for a variable. it is a shell variable... – dfc Oct 18 '11 at 22:00
up vote 2 down vote accepted

Add -vv to the gpg command to see more output. It might have to do with a missing ~/.gnupg though.

share|improve this answer
Thank you, that pointed me into the right direction: --no-tty – MrG Oct 14 '10 at 10:37

/usr/bin/gpg --no-tty --passphrase-file /home/vouuuuuuuuu/settings/passfile.txt --decrypt-files /home/juhuuu/dirname/*.gpg;

works fine now thank to --no-tty before in cron job log gpg: cannot open `/dev/tty': No such device or address so it could not execute before, now is fine!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.