An environment variable contains a value that affects the runtime behaviors of applications. All the systems uses the environment variable that is accessible throughout the system. Some of the cronjobs required a few environment variables to set. This tutorial will help you to set environment variables in crontab jobs.
Advertisement
- The Debian-based systems use the vixie-cron its replacement mcron system, which allows declaring environment variables in the crontab file. For example:1234LANG=nb_NO.UTF-8LC_ALL=nb_NO.UTF-8* * * * * echo "Hello world"
- The RedHat and Arch Linux systems use cronie that uses standard Unix crond daemon. This doesn’t allow for the declaration of environment variables in the crontab file. But, we can still use this with the crontab per entry:1* * * * * export LC_ALL=nb_NO.UTF-8; echo "Hello World"