How to run gpg from a script run by cron?

后端 未结 7 1301
予麋鹿
予麋鹿 2021-02-05 04:10

I have a script that has a part that looks like that:

for file in `ls *.tar.gz`; do
  echo encrypting $file
  gpg --passphrase-file /home/$USER/.gnupg/backup-pas         


        
7条回答
  •  终归单人心
    2021-02-05 04:30

    @skinp Cron jobs are executed by sh, whereas most modern Unixes use bash or ksh for interactive logins. The biggest problem (in my experience) is that sh doesn't understand things like:

    export PS1='\u@\h:\w> '
    

    which needs to be changed to:

    PS1='\u@\h:\w> '
    export PS1
    

    So if cron runs a shell script which defines an environment variable using the first syntax, before running some other command, the other command will never be executed because sh bombs out trying to define the variable.

提交回复
热议问题