How to run gpg from a script run by cron?

后端 未结 7 1396
予麋鹿
予麋鹿 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:19

    I've came across this problem once.

    I can't really tell you why, but I dont think cron executes with the same environment variable as the user do.

    I actually had to export the good path for my programs to execute well. Is gpg at least trying to execute?

    Or are the files you are trying to encypt actually in the current directory when the cron executes?

    Maybe try to execute a echo whereis gpg and echo $PATH in your script to see if it's included... Worked for me.

提交回复
热议问题