Both the shell and environment variables that cronjobs are run in is completely different from the ones presented to me in gnome-terminal. How can I run a cronjob under the same circumstances as if I had run it in the terminal?My current solution is running the cronjob env DISPLAY=:0.0 gnome-terminal -e my-command, but this pops up a gnome-terminal, which isn't really acceptable.
How to run a cronjob in my regular environment?
environment variables;cron
You can either explicitly specify the environment variables you want at the top of your crontab, or you can source your environment from somewhere.To add environment variables explicitly, you can use a line like this at the top of your script (after the hashbang):FOO=barTo source them from a file, use a line like this:. /foo/bar/bazIn response to your edit of your question to include gpg-agent, you should be able to source ~/.gpg-agent-info to get $GPG_AGENT_INFO. If it does not exist, try starting gpg-agent with --write-env-file ${HOME}/.gpg-agent-info.